Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): add share link actions to screenshot editor UI
Richie McIlroy8a83ca86c105
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsxindex 9ab219e13..2d072cacc 100644--- a/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx+++ b/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx@@ -8,6 +8,11 @@ import type { ComponentProps } from "solid-js";import { createMemo, createSignal, Show, splitProps } from "solid-js";import toast from "solid-toast";import Tooltip from "~/components/Tooltip";+import {+ createScreenshotShareLinkFromProjectPath,+ type ScreenshotExportStatus,+ screenshotShareStatusText,+} from "~/routes/screenshot-editor/screenshotExport";import { openRecordingFolder } from "~/utils/recording";import {type CaptureDisplayWithThumbnail,@@ -84,6 +89,9 @@ export default function TargetCard(props: TargetCardProps) {"highlightQuery",]);const [imageExists, setImageExists] = createSignal(true);+ const [isSharingScreenshot, setIsSharingScreenshot] = createSignal(false);+ const [screenshotShareStatus, setScreenshotShareStatus] =+ createSignal<ScreenshotExportStatus>("idle");const recordingProps = () => {if (local.variant !== "recording") return undefined;@@ -253,6 +261,38 @@ export default function TargetCard(props: TargetCardProps) {}};+ const handleShareScreenshot = async (e: MouseEvent) => {+ e.stopPropagation();+ if (isSharingScreenshot()) return;++ const screenshot = screenshotTarget();+ if (!screenshot) return;++ setIsSharingScreenshot(true);+ setScreenshotShareStatus("rendering");+ const toastId = toast.loading(screenshotShareStatusText("rendering"));++ try {+ await createScreenshotShareLinkFromProjectPath(+ screenshot.path,+ (status) => {+ setScreenshotShareStatus(status);+ if (status !== "idle") {+ toast.loading(screenshotShareStatusText(status), { id: toastId });+ }+ },+ );+ toast.success("Share link copied to clipboard", { id: toastId });+ } catch (error) {+ console.error("Failed to create screenshot share link:", error);+ const message = error instanceof Error ? error.message : String(error);+ toast.error(message || "Failed to create share link", { id: toastId });+ } finally {+ setIsSharingScreenshot(false);+ setScreenshotShareStatus("idle");+ }+ };+const handleOpenRecordingEditor = (e: MouseEvent) => {e.stopPropagation();const recording = recordingTarget();@@ -425,6 +465,34 @@ export default function TargetCard(props: TargetCardProps) {<IconLucideSave class="size-3.5" /></div></Tooltip>+ <Tooltip+ content={screenshotShareStatusText(screenshotShareStatus())}+ >+ <div+ role="button"+ tabIndex={-1}+ aria-disabled={isSharingScreenshot()}+ onClick={handleShareScreenshot}+ class={cx(+ "flex-1 flex items-center justify-center p-1 rounded-sm hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors",+ isSharingScreenshot() &&+ "pointer-events-none opacity-60 hover:bg-transparent",+ )}+ >+ <Show+ when={isSharingScreenshot()}+ fallback={<IconCapLink class="size-3.5" />}+ >+ <ProgressCircle+ variant="primary"+ progress={+ screenshotShareStatus() === "uploading" ? 0.65 : 0.25+ }+ size="xs"+ />+ </Show>+ </div>+ </Tooltip></div></Show><Show when={local.variant === "recording"}>diff --git a/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx b/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsxindex 87843f489..68e91d52d 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/screenshots.tsx@@ -16,7 +16,13 @@ import {type ParentProps,Show,} from "solid-js";+import toast from "solid-toast";import { Input } from "~/routes/editor/ui";+import {+ createScreenshotShareLinkFromProjectPath,+ type ScreenshotExportStatus,+ screenshotShareStatusText,+} from "~/routes/screenshot-editor/screenshotExport";import { trackEvent } from "~/utils/analytics";import { createTauriEventListener } from "~/utils/createEventListener";import { importImageFromPicker, showImportError } from "~/utils/importMedia";@@ -27,6 +33,7 @@ import IconLucideCopy from "~icons/lucide/copy";import IconLucideEdit from "~icons/lucide/edit";import IconLucideFolder from "~icons/lucide/folder";import IconLucideImport from "~icons/lucide/import";+import IconLucideLink from "~icons/lucide/link";import IconLucideSearch from "~icons/lucide/search";import { Section, SettingsPageContent } from "./Setting";@@ -50,6 +57,9 @@ export default function Screenshots() {const trimmedSearch = createMemo(() => search().trim());const normalizedSearch = createMemo(() => trimmedSearch().toLowerCase());const [visibleCount, setVisibleCount] = createSignal(PAGE_SIZE);+ const [sharingPath, setSharingPath] = createSignal<string | null>(null);+ const [shareStatus, setShareStatus] =+ createSignal<ScreenshotExportStatus>("idle");const screenshots = createQuery(() => screenshotsQuery);@@ -115,6 +125,32 @@ export default function Screenshots() {commands.copyScreenshotToClipboard(path);};+ const handleCreateShareableLink = async (path: string) => {+ if (sharingPath()) return;++ trackEvent("screenshot_share_clicked");+ setSharingPath(path);+ setShareStatus("rendering");+ const toastId = toast.loading(screenshotShareStatusText("rendering"));++ try {+ await createScreenshotShareLinkFromProjectPath(path, (status) => {+ setShareStatus(status);+ if (status !== "idle") {+ toast.loading(screenshotShareStatusText(status), { id: toastId });+ }+ });+ toast.success("Share link copied to clipboard", { id: toastId });+ } catch (error) {+ console.error("Failed to create screenshot share link:", error);+ const message = error instanceof Error ? error.message : String(error);+ toast.error(message || "Failed to create share link", { id: toastId });+ } finally {+ setSharingPath(null);+ setShareStatus("idle");+ }+ };+const handleImportImage = async () => {try {await importImageFromPicker();@@ -193,6 +229,15 @@ export default function Screenshots() {onCopyImageToClipboard={() =>handleCopyImageToClipboard(screenshot.path)}+ onCreateShareableLink={() =>+ handleCreateShareableLink(screenshot.path)+ }+ isSharing={sharingPath() === screenshot.path}+ shareTooltipText={+ sharingPath() === screenshot.path+ ? screenshotShareStatusText(shareStatus())+ : screenshotShareStatusText("idle")+ }/>)}</For>@@ -229,6 +274,9 @@ function ScreenshotItem(props: {onOpenEditor: () => void;onOpenFolder: () => void;onCopyImageToClipboard: () => void;+ onCreateShareableLink: () => void;+ isSharing: boolean;+ shareTooltipText: string;}) {const [imageExists, setImageExists] = createSignal(true);const queryClient = useQueryClient();@@ -276,6 +324,14 @@ function ScreenshotItem(props: {<IconLucideCopy class="size-4" /></TooltipIconButton>+ <TooltipIconButton+ tooltipText={props.shareTooltipText}+ onClick={props.onCreateShareableLink}+ disabled={props.isSharing}+ >+ <IconLucideLink class="size-4" />+ </TooltipIconButton>+<TooltipIconButtontooltipText="Delete"onClick={async () => {diff --git a/apps/desktop/src/routes/screenshot-editor/Header.tsx b/apps/desktop/src/routes/screenshot-editor/Header.tsxindex 044db0bef..a41171e16 100644--- a/apps/desktop/src/routes/screenshot-editor/Header.tsx+++ b/apps/desktop/src/routes/screenshot-editor/Header.tsx@@ -12,6 +12,7 @@ import IconCapCrop from "~icons/cap/crop";import IconCapTrash from "~icons/cap/trash";import IconLucideCopy from "~icons/lucide/copy";import IconLucideFolder from "~icons/lucide/folder";+import IconLucideLink from "~icons/lucide/link";import IconLucideMoreHorizontal from "~icons/lucide/more-horizontal";import IconLucideSave from "~icons/lucide/save";import { AnnotationTools } from "./AnnotationTools";@@ -43,7 +44,7 @@ export function Header() {} = ctx;const path = () => ctx.editorInstance()?.path ?? "";- const { exportImage, isExporting } = useScreenshotExport();+ const { exportImage, exportStatus, isExporting } = useScreenshotExport();createEffect(() => {const handleKeyDown = (e: KeyboardEvent) => {@@ -92,6 +93,18 @@ export function Header() {};const isCropDisabled = () => !originalImageSize() || !isImageFileReady();+ const shareTooltip = () => {+ switch (exportStatus()) {+ case "rendering":+ return "Rendering screenshot";+ case "encoding":+ return "Preparing upload";+ case "uploading":+ return "Uploading screenshot";+ default:+ return "Create shareable link";+ }+ };return (<div@@ -145,11 +158,19 @@ export function Header() {leftIcon={<IconLucideSave class="size-4" />}/>+ <EditorButton+ tooltipText={shareTooltip()}+ onClick={() => exportImage("share")}+ disabled={isExporting()}+ leftIcon={<IconLucideLink class="size-4" />}+ />+<DropdownMenu gutter={8} placement="bottom-end"><EditorButton<typeof DropdownMenu.Trigger>as={DropdownMenu.Trigger}tooltipText="More Actions"leftIcon={<IconLucideMoreHorizontal class="size-4" />}+ disabled={isExporting()}/><DropdownMenu.Portal><Suspense>