Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(community): share message as image + menu icon cleanup

Shelly#386341a3b040a3f7
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 524e117b9..62389c925 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -390,6 +390,9 @@ importers:
gsap:
specifier: ^3.15.0
version: 3.15.0
+ html-to-image:
+ specifier: ^1.11.13
+ version: 1.11.13
idb:
specifier: ^8.0.3
version: 8.0.3
@@ -3054,6 +3057,10 @@ packages:
resolution: {integrity: sha512-zCKpyDIWKHwtervNK2ZlaK8mMV7gVUijAgFeJStH+CU/imcdquizV3pFLlSQYRswG+Lbyd6CT/LGRh3IbtkCFw==}
engines: {node: '>=8'}
+ '@shaderfrog/[email protected]':
+ resolution: {integrity: sha512-8mpfsoPeRhesY3pOrzNZBL8uG6N5GVX1EHLBYbd4gzKs+c7vaEIqpTNK5VrffU33qQN4cwpP2v3u4aPPBU32sw==}
+ engines: {node: '>=16'}
+
'@shikijs/[email protected]':
resolution: {integrity: sha512-ANMDxuaPsNMdDC1m4vfvhlDmJweMwkE5XitTwrq2rWHx5jM+dlm4MmHt2PP6t0uejfR77SuhrhJ0zEijIF/uhA==}
engines: {node: '>=20'}
@@ -5195,8 +5202,8 @@ packages:
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
engines: {node: '>=6'}
- resolution: {integrity: sha512-eo3Tn37bqC1mMS3BwsdwRITYgQQQdT30g8SMY9C/zRbMu6ekNf9o7aGNUEkxWiKd1dTND58Sndi5fBlT9V6UvA==}
+ resolution: {integrity: sha512-rGhQ17gHnmsjG5KFJM4+oN4bOxktHiPGqzJxKqWt0Qw/NLZIsEgLH1wIo1tTXRyN/MNwhchKbfUieFiWyAh0pQ==}
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
@@ -6106,6 +6113,9 @@ packages:
resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==}
+ resolution: {integrity: sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg==}
+
resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==}
@@ -7476,8 +7486,8 @@ packages:
resolution: {integrity: sha512-FY91FiDBj7ls5MsFS9jN3tjz2o0/zsdSsymlakySaBwVJZorHhkWyICLZMKxlu1R9vYo+sd3z1jwb4J8x7bNDw==}
- resolution: {integrity: sha512-yCW8USbiuszbVsUMN4fL1iU7mRu3Ae3w96+k/xqCyWvW6bF6DzCMtLy5N/w6WLRX78iQsWxVqW/SEgzRBXLfsA==}
+ resolution: {integrity: sha512-fTciSOgAGe/KAgvFDKLz9crjxHyAuu0BvT5sXfSdo2B5QmY5Y/j3nliqX6FaGr7Wud1SYvkAky+/m+58b6K6fQ==}
engines: {node: ^20.19.0 || >=22.13.0}
@@ -7818,8 +7828,8 @@ packages:
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
hasBin: true
- resolution: {integrity: sha512-pKCWENXuYZK7UNBHpNLbEBlpy+oVWwPnOxTD2B//gmrQLm+UvIknArzP3IOjNP5Nk1NKCR9uavypFA1QMbYFyg==}
+ resolution: {integrity: sha512-A/e21t0y3j7zUTS8lJyNI2pKMfYLDH+zZwqAC7+MQW1vCD3xqWc2x8XCCWKnrQQwtFd6dwSZw2017x1iSLnGTA==}
engines: {node: ^20.19.0 || >=22.13.0}
hasBin: true
@@ -11691,6 +11701,8 @@ snapshots:
dependencies:
'@sentry/types': 7.120.4
+ '@shaderfrog/[email protected]': {}
+
'@shikijs/[email protected]':
dependencies:
'@shikijs/primitive': 4.3.1
@@ -12780,7 +12792,7 @@ snapshots:
obug: 2.1.3
std-env: 4.2.0
tinyrainbow: 3.1.0
'@vitest/[email protected]':
dependencies:
@@ -13895,7 +13907,7 @@ snapshots:
dependencies:
'@oxc-project/types': 0.141.0
fast-glob: 3.3.3
@@ -14221,8 +14233,8 @@ snapshots:
'@next/eslint-plugin-next': 16.2.11
eslint: 9.39.5([email protected])
eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
+ eslint-plugin-import: 2.32.0([email protected])([email protected]([email protected]))
eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))
eslint-plugin-react: 7.37.5([email protected]([email protected]))
eslint-plugin-react-hooks: 7.1.1([email protected]([email protected]))
@@ -14244,7 +14256,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3
@@ -14255,21 +14267,21 @@ snapshots:
tinyglobby: 0.2.17
unrs-resolver: 1.12.2
optionalDependencies:
+ eslint-plugin-import: 2.32.0([email protected])([email protected]([email protected]))
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
eslint: 9.39.5([email protected])
eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
transitivePeerDependencies:
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.9
@@ -14280,7 +14292,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.39.5([email protected])
eslint-import-resolver-node: 0.3.10
hasown: 2.0.4
is-core-module: 2.16.2
is-glob: 4.0.3
@@ -15114,6 +15126,8 @@ snapshots:
+
@@ -16870,8 +16884,9 @@ snapshots:
'@oxc-resolver/binding-win32-arm64-msvc': 11.24.2
'@oxc-resolver/binding-win32-x64-msvc': 11.24.2
dependencies:
+ '@shaderfrog/glsl-parser': 7.0.1
'@typescript-eslint/types': 8.65.0
eslint-scope: 9.1.2
eslint-visitor-keys: 5.0.1
@@ -17276,22 +17291,23 @@ snapshots:
minimist: 1.2.8
strip-json-comments: 2.0.1
dependencies:
'@babel/code-frame': 7.29.7
'@sentry/node': 10.68.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))
agent-install: 0.0.5
conf: 15.1.0
confbox: 0.2.4
- deslop-js: 0.9.1
+ deslop-js: 0.9.2
eslint-plugin-react-hooks: 7.1.1([email protected]([email protected]))
figures: 6.1.0
jiti: 2.7.0
magicast: 0.5.3
+ oxc-resolver: 11.24.2
oxlint: 1.74.0
- oxlint-plugin-react-doctor: 0.9.1
+ oxlint-plugin-react-doctor: 0.9.2
prompts: 2.4.2
react: 19.2.5
typescript: 5.9.3
@@ -17355,7 +17371,7 @@ snapshots:
preact: 10.29.7
prompts: 2.4.2
react: 19.2.8
- react-doctor: 0.9.1(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@types/[email protected])([email protected]([email protected]))
+ react-doctor: 0.9.2(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@types/[email protected])([email protected]([email protected]))
react-dom: 19.2.8([email protected])
react-grab: 0.1.50([email protected])
optionalDependencies:
diff --git a/src/web/package.json b/src/web/package.json
index 91392a759..c948affdc 100644
--- a/src/web/package.json
+++ b/src/web/package.json
@@ -67,6 +67,7 @@
"driver.js": "^1.8.0",
"emoji-mart": "^5.6.0",
"gsap": "^3.15.0",
+ "html-to-image": "^1.11.13",
"idb": "^8.0.3",
"idb-keyval": "^6.3.0",
"input-otp": "^1.4.2",
diff --git a/src/web/src/components/community/message-menu.test.ts b/src/web/src/components/community/message-menu.test.ts
new file mode 100644
index 000000000..2c3ee23be
--- /dev/null
+++ b/src/web/src/components/community/message-menu.test.ts
@@ -0,0 +1,47 @@
+import { describe, it, expect, vi } from "vitest"
+import { messageMenuItems, hasMessageMenu } from "./message-menu"
+
+// The menu is contract-driven: each item appears ONLY when its handler is
+// supplied, so a surface that can't drive an action omits it (no dead entries).
+describe("messageMenuItems", () => {
+ it("omits every item when no handlers are given", () => {
+ expect(messageMenuItems({})).toEqual([])
+ expect(hasMessageMenu({})).toBe(false)
+ })
+
+ it("includes 'Share as Image' only when onShare is provided", () => {
+ expect(messageMenuItems({}).some((it) => it.label === "Share as Image")).toBe(false)
+ const items = messageMenuItems({ onShare: () => {} })
+ expect(items.some((it) => it.label === "Share as Image")).toBe(true)
+ })
+
+ it("wires the Share item's onClick to the provided handler", () => {
+ const onShare = vi.fn()
+ const share = messageMenuItems({ onShare }).find((it) => it.label === "Share as Image")
+ share?.onClick?.()
+ expect(onShare).toHaveBeenCalledOnce()
+ })
+
+ it("gives only the high-frequency actions (Reply, Share) an icon; the rest text-only", () => {
+ // Locked spec (uiux #14): single list; icons only on Reply + Share as
+ // navigation anchors; low-freq actions are text (icon slot → placeholder).
+ const items = messageMenuItems({
+ onReply: () => {}, onShare: () => {}, onAddReaction: () => {},
+ onCreateThread: () => {}, onPin: () => {}, onCopy: () => {},
+ })
+ const iconLabels = items.filter((it) => it.icon).map((it) => it.label)
+ expect(iconLabels).toEqual(["Reply", "Share as Image"])
+ for (const label of ["Add Reaction", "Create Thread", "Pin Message", "Copy Text"]) {
+ expect(items.find((it) => it.label === label)?.icon).toBeUndefined()
+ }
+ })
+
+ it("keeps the original row order — icons don't reorder the list (uiux #19)", () => {
+ const labels = messageMenuItems({
+ onReply: () => {}, onShare: () => {}, onAddReaction: () => {},
+ onCreateThread: () => {}, onPin: () => {}, onCopy: () => {},
+ }).map((it) => it.label)
+ expect(labels).toEqual(["Add Reaction", "Reply", "Create Thread", "Pin Message", "Copy Text", "Share as Image"])
+ expect(labels).not.toContain("sep")
+ })
+})
diff --git a/src/web/src/components/community/message-menu.tsx b/src/web/src/components/community/message-menu.tsx
index 5783f1c22..fed9bde64 100644
--- a/src/web/src/components/community/message-menu.tsx
+++ b/src/web/src/components/community/message-menu.tsx
@@ -1,15 +1,25 @@
-import { SmilePlus, Reply, Pin, PinOff, MessagesSquare, Copy } from "lucide-react"
-import { ContextMenuItem, ContextMenuSeparator } from "@/components/ui/context-menu"
-import { DropdownMenuItem, DropdownMenuSeparator } from "@/components/ui/dropdown-menu"
+import { Reply, Pin, Share } from "lucide-react"
+import { ContextMenuItem } from "@/components/ui/context-menu"
+import { DropdownMenuItem } from "@/components/ui/dropdown-menu"
// Shared message-action items, rendered for either a ContextMenu (right-click) or a
// DropdownMenu (⋯ toolbar). Callbacks are the reusable contract; the preview wires
// preview-local handlers, the live app wires API mutations.
type Item = { label: string; icon?: typeof Pin; danger?: boolean; onClick?: () => void }
+// Menu design (locked spec, uiux #14 — Gus/Alli, "less is more"): ONE flat list, no
+// sections/divider. Only the HIGH-FREQUENCY actions carry an icon (Reply, Share) —
+// there the icon is a navigation anchor you scan straight to. The low-frequency
+// actions (React / Thread / Pin / Copy) are text only: their labels are
+// self-explanatory, so an icon adds no recognition value, just noise. To keep every
+// label's left edge aligned, the icon-less rows render an icon-width placeholder in
+// the icon slot (see `renderItem` below) rather than shifting flush-left.
+
// Each item renders only when its handler is provided. A surface that can't drive an
// action (e.g. read-only thread/DM rows that don't wire Pin/Select) simply omits it —
// no dead menu entries. The channel list passes every handler → the full menu.
+// Order is UNCHANGED from before the redesign (Gus, uiux #19 — don't hoist the iconic
+// actions to the top): the only change is WHICH rows carry an icon, not their order.
export function messageMenuItems(handlers: {
onAddReaction?: () => void
onReply?: () => void
@@ -17,38 +27,45 @@ export function messageMenuItems(handlers: {
pinned?: boolean
onCreateThread?: () => void
onCopy?: () => void
+ onShare?: () => void
}): Item[] {
const items: Item[] = []
- if (handlers.onAddReaction) items.push({ label: "Add Reaction", icon: SmilePlus, onClick: handlers.onAddReaction })
+ // Reply + Share are high-frequency → keep the icon; the rest are text only (their
+ // icon slot becomes an aligning placeholder at render). Original ordering preserved.
+ if (handlers.onAddReaction) items.push({ label: "Add Reaction", onClick: handlers.onAddReaction })
if (handlers.onReply) items.push({ label: "Reply", icon: Reply, onClick: handlers.onReply })
- if (handlers.onCreateThread) items.push({ label: "Create Thread", icon: MessagesSquare, onClick: handlers.onCreateThread })
+ if (handlers.onCreateThread) items.push({ label: "Create Thread", onClick: handlers.onCreateThread })
if (handlers.onPin) items.push(handlers.pinned
- ? { label: "Unpin Message", icon: PinOff, onClick: handlers.onPin }
- : { label: "Pin Message", icon: Pin, onClick: handlers.onPin })
- if (handlers.onCopy) items.push({ label: "Copy Text", icon: Copy, onClick: handlers.onCopy })
+ ? { label: "Unpin Message", onClick: handlers.onPin }
+ : { label: "Pin Message", onClick: handlers.onPin })
+ if (handlers.onCopy) items.push({ label: "Copy Text", onClick: handlers.onCopy })
+ if (handlers.onShare) items.push({ label: "Share as Image", icon: Share, onClick: handlers.onShare })
return items
}
// True when at least one action is available — callers use this to decide whether to
// render the ⋯ trigger / context-menu wrapper at all.
export function hasMessageMenu(handlers: Parameters<typeof messageMenuItems>[0]) {
- return messageMenuItems(handlers).some((it) => it.label !== "sep")
+ return messageMenuItems(handlers).length > 0
}
export type MessageMenuHandlers = Parameters<typeof messageMenuItems>[0]
+// The icon slot: the real icon for high-freq rows, or an equal-width empty
+// placeholder for text-only rows so every label shares one left edge. The menu
+// item's own `gap-2` handles the spacing to the label either way.
+function IconSlot({ icon: Icon }: { icon?: Item["icon"] }) {
+ return Icon ? <Icon className="size-4" /> : <span className="size-4" aria-hidden />
+}
+
export function MessageContextItems(props: MessageMenuHandlers) {
return (
<>
- {messageMenuItems(props).map((it, i) =>
- it.label === "sep" ? (
- <ContextMenuSeparator key={i} />
- ) : (
- <ContextMenuItem key={it.label} onClick={it.onClick} className={it.danger ? "text-destructive data-highlighted:bg-destructive/10 data-highlighted:text-destructive" : ""}>
- {it.icon && <it.icon className="size-4" />} {it.label}
- </ContextMenuItem>
- ),
- )}
+ {messageMenuItems(props).map((it) => (
+ <ContextMenuItem key={it.label} onClick={it.onClick} className={it.danger ? "text-destructive data-highlighted:bg-destructive/10 data-highlighted:text-destructive" : ""}>
+ <IconSlot icon={it.icon} /> {it.label}
+ </ContextMenuItem>
+ ))}
</>
)
}
@@ -56,15 +73,11 @@ export function MessageContextItems(props: MessageMenuHandlers) {
export function MessageDropdownItems(props: MessageMenuHandlers) {
return (
<>
- {messageMenuItems(props).map((it, i) =>
- it.label === "sep" ? (
- <DropdownMenuSeparator key={i} />
- ) : (
- <DropdownMenuItem key={it.label} onClick={it.onClick} variant={it.danger ? "destructive" : "default"}>
- {it.icon && <it.icon className="size-4" />} {it.label}
- </DropdownMenuItem>
- ),
- )}
+ {messageMenuItems(props).map((it) => (
+ <DropdownMenuItem key={it.label} onClick={it.onClick} variant={it.danger ? "destructive" : "default"}>
+ <IconSlot icon={it.icon} /> {it.label}
+ </DropdownMenuItem>
+ ))}
</>
)
}
diff --git a/src/web/src/components/community/message-share-dialog.tsx b/src/web/src/components/community/message-share-dialog.tsx
new file mode 100644
index 000000000..d247e7ae3
--- /dev/null
+++ b/src/web/src/components/community/message-share-dialog.tsx
@@ -0,0 +1,164 @@
+"use client"
+
+import { useRef, useState } from "react"
+import Image from "next/image"
+import { toBlob } from "html-to-image"
+import { toast } from "sonner"
+import { Check, Copy, Download, Loader2 } from "lucide-react"
+import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"
+import { Button } from "@/components/ui/button"
+import { Avatar } from "./avatar"
+import { MessageBody } from "./message-body"
+import { tid } from "@/lib/community/testids"
+import type { RenderMsg } from "./_types"
+
+// Share a single message as an image. Renders a self-contained "share card"
+// that mirrors the in-app message blob (avatar / name / content — NO timestamp,
+// per spec) plus an Alook brand footer, then rasterises THAT SAME node to PNG
+// (WYSIWYG) via html-to-image — fully client-side, no backend. The captured
+// node has a fixed width and its own solid background so the export is stable
+// regardless of the surrounding theme surface.
+export function MessageShareDialog({ m, open, onClose }: {
+ m: RenderMsg
+ open: boolean
+ onClose: () => void
+}) {
+ const cardRef = useRef<HTMLDivElement>(null)
+ const [busy, setBusy] = useState<"copy" | "download" | null>(null)
+ const [copied, setCopied] = useState(false)
+
+ // Rasterise the card node to a PNG blob. pixelRatio 2 for a crisp image on
+ // retina / when pasted into other apps. `cacheBust` avoids stale cross-origin
+ // image reuse; the card is same-origin so fonts + the logo embed cleanly.
+ const render = async (): Promise<Blob | null> => {
+ const node = cardRef.current
+ if (!node) return null
+ // Guarantee the Caveat brand font is loaded BEFORE rasterising. html-to-image
+ // inlines webfonts into the SVG it draws; if Caveat's async @font-face hasn't
+ // resolved yet, the footer silently falls back to a default font and the PNG
+ // differs machine-to-machine ("fine on mine, blurry/wrong on theirs"). Awaiting
+ // the specific face (then the global ready signal) closes that race.
+ try {
+ if (document.fonts?.load) await document.fonts.load('16px "Caveat"')
+ await document.fonts?.ready
+ } catch {
+ // Font API unavailable / load rejected — proceed; worst case is the
+ // footer's fallback font, not a failed export.
+ }
+ return toBlob(node, {
+ pixelRatio: 2,
+ // Re-fetch + inline external images (e.g. an uploaded CDN avatar) rather
+ // than reusing a possibly-tainted cached bitmap — avoids the canvas-taint
+ // path that would drop the avatar from the PNG. Beam fallbacks are our own
+ // inline SVG, so they're unaffected either way.
+ cacheBust: true,
+ // Solid backdrop so the exported PNG never bleeds transparent corners
+ // (the card's own rounded bg sits on top of this).
+ backgroundColor: getComputedStyle(node).getPropertyValue("--card")?.trim() || undefined,
+ })
+ }
+
+ const copy = async () => {
+ setBusy("copy")
+ try {
+ const blob = await render()
+ if (!blob) throw new Error("render failed")
+ // ClipboardItem image write — supported in modern Chromium/Safari/FF.
+ await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })])
+ setCopied(true)
+ toast.success("Image copied to clipboard")
+ window.setTimeout(() => setCopied(false), 1600)
+ } catch {
+ toast.error("Couldn't copy image — try Download instead")
+ } finally {
+ setBusy(null)
+ }
+ }
+
+ const download = async () => {
+ setBusy("download")
+ try {
+ const blob = await render()
+ if (!blob) throw new Error("render failed")
+ const url = URL.createObjectURL(blob)
+ const a = document.createElement("a")
+ a.href = url
+ a.download = `alook-message-${m.authorName ?? "share"}.png`
+ a.click()
+ URL.revokeObjectURL(url)
+ } catch {
+ toast.error("Couldn't generate image")
+ } finally {
+ setBusy(null)
+ }
+ }
+
+ return (
+ <Dialog open={open} onOpenChange={(o) => !o && onClose()}>
+ {/* NOTE: DialogContent's base class carries `sm:max-w-sm` (384px). That's
+ a responsive variant, so it sorts AFTER a plain `max-w-[…]` in the
+ generated CSS and would silently cap the dialog at 384px — the reason a
+ wider `w-*` "doesn't take effect". Override it with a matching `sm:`
+ max-width so the width below can actually apply. */}
+ <DialogContent className="w-180 max-w-[calc(100vw-2rem)] sm:max-w-[calc(100vw-2rem)] gap-0 p-0">
+ <DialogHeader className="px-5 pt-5 pb-3">
+ <DialogTitle>Share message</DialogTitle>
+ </DialogHeader>
+
+ {/* Preview area — the padding frames the card; the card itself is what
+ gets captured. */}
+ <div className="bg-muted/40 px-6 py-6">
+ {/* The card takes the full preview width — a generous, poster-like
+ default so the share image reads as a proper card at any content
+ length (a short message just has more breathing room, rather than
+ collapsing to a narrow chip). */}
+ <div
+ ref={cardRef}
+ className="overflow-hidden rounded-xl bg-card p-5 shadow-(--e1)"
+ >
+ <div className="flex gap-3">
+ <Avatar label={m.authorAvatar ?? "?"} seed={m.authorId} size={40} />
+ <div className="min-w-0 flex-1">
+ <div
+ className="mb-0.5 text-[15px] font-semibold"
+ style={{ color: m.color ?? "var(--foreground)" }}
+ >
+ {m.authorName}
+ </div>
+ {m.content && <MessageBody text={m.content} />}
+ </div>
+ </div>
+
+ {/* Brand footer — Alook logo + brand font, mirrors the marketing
+ footer treatment. */}
+ <div className="mt-4 flex items-center gap-1.5 border-t border-border/50 pt-3">
+ <Image src="/alook.svg" alt="" width={16} height={16} />
+ <span
+ className="text-sm font-bold tracking-tight text-muted-foreground"
+ style={{ fontFamily: "var(--font-brand)" }}
+ >
+ Alook
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div className="flex justify-end gap-2 px-5 pt-3 pb-5">
+ <Button variant="ghost" size="sm" onClick={download} disabled={busy !== null}>
+ {busy === "download" ? <Loader2 className="animate-spin" /> : <Download />}
+ Download
+ </Button>
+ <Button
+ size="sm"
+ data-testid={tid.messageShareCopy}
+ onClick={copy}
+ disabled={busy !== null}
+ >
+ {busy === "copy" ? <Loader2 className="animate-spin" /> : copied ? <Check /> : <Copy />}
+ {copied ? "Copied" : "Copy image"}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/src/web/src/components/community/message.tsx b/src/web/src/components/community/message.tsx
index ce152cc83..5316df31c 100644
--- a/src/web/src/components/community/message.tsx
+++ b/src/web/src/components/community/message.tsx
@@ -4,12 +4,13 @@ import { memo, useState } from "react"
import type React from "react"
import {
MessagesSquare, UserPlus, SmilePlus, Reply,
- MoreHorizontal, FileText, Download, X,
+ MoreHorizontal, FileText, Download, X, Share,
} from "lucide-react"
import { ContextMenu, ContextMenuTrigger, ContextMenuContent } from "@/components/ui/context-menu"
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from "@/components/ui/dropdown-menu"
import { Avatar } from "./avatar"
import { MessageBody } from "./message-body"
+import { MessageShareDialog } from "./message-share-dialog"
import { BotApprovalCard } from "./bot-approval-card"
import { EmojiPickerPopover } from "./emoji-picker"
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"
@@ -66,6 +67,9 @@ function MessageImpl({
// hover OR focus OR keydown/contextmenu — focus/keydown are required for a11y
// (keyboard context menu / Tab-to-row have no pointerenter).
const [activated, setActivated] = useState(false)
+ // Share-as-image dialog. Local to the row — the card is built from `m` alone,
+ // so no callback needs threading through message-list.
+ const [shareOpen, setShareOpen] = useState(false)
if (m.type === "system") {
const Icon = m.systemKind === "thread" ? MessagesSquare : UserPlus
@@ -78,11 +82,16 @@ function MessageImpl({
)
}
+ // Share is only meaningful for a message with rendered text content (the card
+ // mirrors avatar/name/content — an approval/attachment-only row has nothing to
+ // put on it).
+ const canShare = !compact && !m.approval && !!m.content
const menuHandlers = {
onAddReaction: onReact ? () => onReact("👍") : undefined,
onReply, onPin, pinned,
onCreateThread: m.thread ? undefined : onCreateThread,
onCopy,
+ onShare: canShare ? () => setShareOpen(true) : undefined,
}
const showMenu = hasMessageMenu(menuHandlers)
const interactive = !compact && showMenu
@@ -118,6 +127,11 @@ function MessageImpl({
<Reply className="size-4" />
</button>
)}
+ {canShare && (
+ <button data-testid={tid.messageShare(m.id)} onClick={() => setShareOpen(true)} className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none" aria-label="Share as image">
+ <Share className="size-4" />
+ </button>
+ )}
<DropdownMenu onOpenChange={setToolbarOpen}>
<DropdownMenuTrigger
render={<button aria-label="More actions" className="grid size-7 place-items-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-expanded:text-foreground" />}
@@ -346,19 +360,28 @@ function MessageImpl({
</div>
)
+ // The share dialog mounts lazily (only once opened) and is rendered alongside
+ // whichever row variant we return, so it survives across both branches.
+ const shareDialog = canShare && shareOpen ? (
+ <MessageShareDialog m={m} open={shareOpen} onClose={() => setShareOpen(false)} />
+ ) : null
+
// Not interactive, or not yet activated → render the bare row (which carries
// the pointerenter/focus/keydown activation handlers). The row's Base UI
// ContextMenu root is only mounted once hover/focus has activated it — and a
// right-click is always preceded by a pointerenter (mouse arriving on the
// row), and Shift+F10 by focus, so the menu is mounted before it's invoked.
- if (!interactive || !activated) return row
+ if (!interactive || !activated) return <>{row}{shareDialog}</>
return (
- <ContextMenu>
- <ContextMenuTrigger className="select-text" render={row} />
- <ContextMenuContent className="w-48">
- <MessageContextItems {...menuHandlers} />
- </ContextMenuContent>
- </ContextMenu>
+ <>
+ <ContextMenu>
+ <ContextMenuTrigger className="select-text" render={row} />
+ <ContextMenuContent className="w-48">
+ <MessageContextItems {...menuHandlers} />
+ </ContextMenuContent>
+ </ContextMenu>
+ {shareDialog}
+ </>
)
}
diff --git a/src/web/src/components/ui/context-menu.tsx b/src/web/src/components/ui/context-menu.tsx
index 2b4517868..11d9addc1 100644
--- a/src/web/src/components/ui/context-menu.tsx
+++ b/src/web/src/components/ui/context-menu.tsx
@@ -52,7 +52,7 @@ function ContextMenuContent({
>
<ContextMenuPrimitive.Popup
data-slot="context-menu-content"
- className={cn("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
+ className={cn("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-2 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
{...props}
/>
</ContextMenuPrimitive.Positioner>
@@ -78,7 +78,7 @@ function ContextMenuLabel({
data-slot="context-menu-label"
data-inset={inset}
className={cn(
- "px-2 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
+ "px-2 py-2 text-xs font-medium text-muted-foreground data-inset:pl-7",
className
)}
{...props}
@@ -101,7 +101,7 @@ function ContextMenuItem({
data-inset={inset}
data-variant={variant}
className={cn(
- "group/context-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",
+ "group/context-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",
className
)}
{...props}
@@ -128,7 +128,7 @@ function ContextMenuSubTrigger({
data-slot="context-menu-sub-trigger"
data-inset={inset}
className={cn(
- "flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "flex cursor-default items-center gap-2 rounded-md px-2 py-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -166,7 +166,7 @@ function ContextMenuCheckboxItem({
data-slot="context-menu-checkbox-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-default items-center gap-2 rounded-md py-2 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
checked={checked}
@@ -207,7 +207,7 @@ function ContextMenuRadioItem({
data-slot="context-menu-radio-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-default items-center gap-2 rounded-md py-2 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.ts
index 68d77869b..1f9041406 100644
--- a/src/web/src/lib/community/testids.ts
+++ b/src/web/src/lib/community/testids.ts
@@ -26,6 +26,8 @@ export const tid = {
memberRow: (id: string) => `community-member-row-${id}`,
mentionOption: (id: string) => `community-mention-option-${id}`,
reactionAdd: (msgId: string) => `community-reaction-add-${msgId}`,
+ messageShare: (msgId: string) => `community-message-share-${msgId}`,
+ messageShareCopy: `community-message-share-copy`,
threadIndicator: (msgId: string) => `community-thread-indicator-${msgId}`,
railUnreadBadge: (serverId: string) => `community-rail-unread-badge-${serverId}`,
// Forum post feed (ForumView). `forumPostCard` is the whole clickable card;