Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(unfurl): add Supercut and Loom video embed support (#8176)
Jacob Beckerman25d9fc3c0920
diff --git a/apps/web/src/lib/core/component/Link.tsx b/apps/web/src/lib/core/component/Link.tsxindex 5142eaf043..98ef4bb622 100644--- a/apps/web/src/lib/core/component/Link.tsx+++ b/apps/web/src/lib/core/component/Link.tsx@@ -2,6 +2,7 @@ import { openExternalUrl } from '@core/util/url';import LinkIcon from '@phosphor/link.svg';import { proxyResource } from '@service-unfurl/client';import type { GetUnfurlResponse } from '@service-unfurl/generated/schemas/getUnfurlResponse';+import { UnfurlEmbedType } from '@service-unfurl/generated/schemas/unfurlEmbedType';import { cn } from '@ui';import { Show } from 'solid-js';import { createStore } from 'solid-js/store';@@ -25,43 +26,76 @@ type LinkHoverCardProps = {unfurled: GetUnfurlResponse;};+/**+ * Video embed component for services like Loom and Supercut.+ */+function VideoEmbed(props: { embedUrl: string; title: string }) {+ return (+ <div class="w-80 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl glass bg-menu-glass">+ <div class="relative aspect-video w-full">+ <iframe+ src={props.embedUrl}+ class="absolute inset-0 size-full rounded-t-xl"+ allow="clipboard-write; encrypted-media; picture-in-picture; fullscreen"+ allowfullscreen+ title={props.title}+ />+ </div>+ <div class="px-2 py-1.5">+ <div class="truncate text-xs font-medium text-ink">{props.title}</div>+ </div>+ </div>+ );+}+/*** The shared card shown when hovering a link in rendered or editable Markdown.+ * For embeddable video content (Loom, Supercut), renders an iframe player.*/export function LinkHoverCard(props: LinkHoverCardProps) {const domain = extractDomain(props.unfurled.url);const title = () => props.unfurled.title || domain;return (- <div class="flex w-80 max-w-[calc(100vw-1rem)] items-start gap-1 rounded-xl glass bg-menu-glass p-2 text-left">- <div class="flex size-6 shrink-0 items-center justify-center">- <Show- when={props.unfurled.favicon_url}- fallback={<LinkIcon class="size-4 text-ink-muted" />}- >- {(icon) => (+ <Show+ when={+ props.unfurled.embed_type === UnfurlEmbedType.Video &&+ props.unfurled.embed_url+ }+ fallback={+ <div class="flex w-80 max-w-[calc(100vw-1rem)] items-start gap-1 rounded-xl glass bg-menu-glass p-2 text-left">+ <div class="flex size-6 shrink-0 items-center justify-center"><Show- when={!badLinks[icon()]}+ when={props.unfurled.favicon_url}fallback={<LinkIcon class="size-4 text-ink-muted" />}>- <img- src={proxyResource(icon())}- class="size-5 rounded-md object-cover"- crossorigin="anonymous"- alt=""- on:error={() => {- setBadLinks(icon(), true);- }}- />+ {(icon) => (+ <Show+ when={!badLinks[icon()]}+ fallback={<LinkIcon class="size-4 text-ink-muted" />}+ >+ <img+ src={proxyResource(icon())}+ class="size-5 rounded-md object-cover"+ crossorigin="anonymous"+ alt=""+ on:error={() => {+ setBadLinks(icon(), true);+ }}+ />+ </Show>+ )}</Show>- )}- </Show>- </div>- <div class="min-w-0 flex-1">- <div class="truncate text-sm/6 font-medium text-ink">{title()}</div>- <div class="truncate text-xs text-ink-muted">{domain}</div>- </div>- </div>+ </div>+ <div class="min-w-0 flex-1">+ <div class="truncate text-sm/6 font-medium text-ink">{title()}</div>+ <div class="truncate text-xs text-ink-muted">{domain}</div>+ </div>+ </div>+ }+ >+ <VideoEmbed embedUrl={props.unfurled.embed_url!} title={title()} />+ </Show>);}diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponse.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponse.tsindex 9950e6dc91..3c954512d2 100644--- a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponse.ts+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponse.ts@@ -5,8 +5,10 @@* OpenAPI spec version: 0.1.0*/import type { GetUnfurlResponseDescription } from './getUnfurlResponseDescription';+import type { GetUnfurlResponseEmbedUrl } from './getUnfurlResponseEmbedUrl';import type { GetUnfurlResponseFaviconUrl } from './getUnfurlResponseFaviconUrl';import type { GetUnfurlResponseImageUrl } from './getUnfurlResponseImageUrl';+import type { UnfurlEmbedType } from './unfurlEmbedType';/*** Unfurl response for a single URL: the URL itself plus any metadata that@@ -16,6 +18,10 @@ favicon).export interface GetUnfurlResponse {/** The page description (from `og:description`), if any. */description?: GetUnfurlResponseDescription;+ /** The type of embeddable content, if the URL supports iframe embedding. */+ embed_type?: UnfurlEmbedType;+ /** The iframe-embeddable URL for services like Loom or Supercut. */+ embed_url?: GetUnfurlResponseEmbedUrl;/** The page's favicon URL, if any. */favicon_url?: GetUnfurlResponseFaviconUrl;/** The page's preview image URL (from `og:image`), if any. */diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponseEmbedUrl.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponseEmbedUrl.tsnew file mode 100644index 0000000000..4d380f3574--- /dev/null+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/getUnfurlResponseEmbedUrl.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * unfurl_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The iframe-embeddable URL for services like Loom or Supercut.+ */+export type GetUnfurlResponseEmbedUrl = string | null;diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/index.tsindex a76b2da68b..0f8e71aabc 100644--- a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/index.ts+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/index.ts@@ -12,13 +12,16 @@ export * from './getUnfurlParams';export * from './getUnfurlQueryParams';export * from './getUnfurlResponse';export * from './getUnfurlResponseDescription';+export * from './getUnfurlResponseEmbedUrl';export * from './getUnfurlResponseFaviconUrl';export * from './getUnfurlResponseImageUrl';export * from './proxyParams';export * from './proxyRequestHandlerParams';+export * from './unfurlEmbedType';export * from './vec';export * from './vecItem';export * from './vecItemOneOf';export * from './vecItemOneOfDescription';+export * from './vecItemOneOfEmbedUrl';export * from './vecItemOneOfFaviconUrl';export * from './vecItemOneOfImageUrl';diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/unfurlEmbedType.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/unfurlEmbedType.tsnew file mode 100644index 0000000000..836cf2c559--- /dev/null+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/unfurlEmbedType.ts@@ -0,0 +1,18 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * unfurl_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The type of embeddable content for services that support iframe embedding.+ */+export type UnfurlEmbedType =+ (typeof UnfurlEmbedType)[keyof typeof UnfurlEmbedType];++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const UnfurlEmbedType = {+ None: 'None',+ Video: 'Video',+} as const;diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOf.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOf.tsindex c2f7b42704..2eb1bd6db2 100644--- a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOf.ts+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOf.ts@@ -4,7 +4,10 @@* unfurl_service* OpenAPI spec version: 0.1.0*/++import type { UnfurlEmbedType } from './unfurlEmbedType';import type { VecItemOneOfDescription } from './vecItemOneOfDescription';+import type { VecItemOneOfEmbedUrl } from './vecItemOneOfEmbedUrl';import type { VecItemOneOfFaviconUrl } from './vecItemOneOfFaviconUrl';import type { VecItemOneOfImageUrl } from './vecItemOneOfImageUrl';@@ -16,6 +19,10 @@ favicon).export type VecItemOneOf = {/** The page description (from `og:description`), if any. */description?: VecItemOneOfDescription;+ /** The type of embeddable content, if the URL supports iframe embedding. */+ embed_type?: UnfurlEmbedType;+ /** The iframe-embeddable URL for services like Loom or Supercut. */+ embed_url?: VecItemOneOfEmbedUrl;/** The page's favicon URL, if any. */favicon_url?: VecItemOneOfFaviconUrl;/** The page's preview image URL (from `og:image`), if any. */diff --git a/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOfEmbedUrl.ts b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOfEmbedUrl.tsnew file mode 100644index 0000000000..ab854d9f99--- /dev/null+++ b/apps/web/src/lib/service-clients/service-unfurl/generated/schemas/vecItemOneOfEmbedUrl.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * unfurl_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The iframe-embeddable URL for services like Loom or Supercut.+ */+export type VecItemOneOfEmbedUrl = string | null;diff --git a/apps/web/src/lib/service-clients/service-unfurl/openapi.json b/apps/web/src/lib/service-clients/service-unfurl/openapi.jsonindex 1b387844a3..ef38dab604 100644--- a/apps/web/src/lib/service-clients/service-unfurl/openapi.json+++ b/apps/web/src/lib/service-clients/service-unfurl/openapi.json@@ -179,6 +179,14 @@"type": ["string", "null"],"description": "The page description (from `og:description`), if any."},+ "embed_type": {+ "$ref": "#/components/schemas/UnfurlEmbedType",+ "description": "The type of embeddable content, if the URL supports iframe embedding."+ },+ "embed_url": {+ "type": ["string", "null"],+ "description": "The iframe-embeddable URL for services like Loom or Supercut."+ },"favicon_url": {"type": ["string", "null"],"description": "The page's favicon URL, if any."@@ -206,6 +214,11 @@}}},+ "UnfurlEmbedType": {+ "type": "string",+ "description": "The type of embeddable content for services that support iframe embedding.",+ "enum": ["None", "Video"]+ },"Vec": {"type": "array","items": {@@ -222,6 +235,14 @@"type": ["string", "null"],"description": "The page description (from `og:description`), if any."},+ "embed_type": {+ "$ref": "#/components/schemas/UnfurlEmbedType",+ "description": "The type of embeddable content, if the URL supports iframe embedding."+ },+ "embed_url": {+ "type": ["string", "null"],+ "description": "The iframe-embeddable URL for services like Loom or Supercut."+ },"favicon_url": {"type": ["string", "null"],"description": "The page's favicon URL, if any."diff --git a/crates/unfurl/src/domain/models.rs b/crates/unfurl/src/domain/models.rsindex ab45782bec..1b5f8f26a8 100644--- a/crates/unfurl/src/domain/models.rs+++ b/crates/unfurl/src/domain/models.rs@@ -6,7 +6,26 @@ use serde::{Deserialize, Serialize};use thiserror::Error;use url::Url;-use super::url_parsers::parse_custom_title;+use super::url_parsers::{EmbedInfo, EmbedType, parse_custom_title, parse_embed_info};++/// The type of embeddable content for services that support iframe embedding.+#[derive(Debug, Serialize, Deserialize, Default, Clone, Eq, PartialEq)]+#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]+pub enum UnfurlEmbedType {+ /// No embeddable content.+ #[default]+ None,+ /// Video content (Loom, Supercut, etc.).+ Video,+}++impl From<EmbedType> for UnfurlEmbedType {+ fn from(embed_type: EmbedType) -> Self {+ match embed_type {+ EmbedType::Video => UnfurlEmbedType::Video,+ }+ }+}/// Unfurl response for a single URL: the URL itself plus any metadata that/// was extracted from the page's `<head>` (title, description, image,@@ -27,6 +46,16 @@ pub struct GetUnfurlResponse {/// The page's favicon URL, if any.#[serde(default, skip_serializing_if = "Option::is_none")]pub favicon_url: Option<String>,+ /// The type of embeddable content, if the URL supports iframe embedding.+ #[serde(default, skip_serializing_if = "is_embed_type_none")]+ pub embed_type: UnfurlEmbedType,+ /// The iframe-embeddable URL for services like Loom or Supercut.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub embed_url: Option<String>,+}++fn is_embed_type_none(embed_type: &UnfurlEmbedType) -> bool {+ matches!(embed_type, UnfurlEmbedType::None)}impl GetUnfurlResponse {@@ -68,12 +97,23 @@ impl GetUnfurlResponse {favicon_url = Some(joined.to_string());}+ // Check for embeddable content (video services like Loom, Supercut).+ let (embed_type, embed_url) = match parse_embed_info(url) {+ Some(EmbedInfo {+ embed_type,+ embed_url,+ }) => (embed_type.into(), Some(embed_url)),+ None => (UnfurlEmbedType::None, None),+ };+GetUnfurlResponse {url: url.to_string(),title,description,image_url,favicon_url,+ embed_type,+ embed_url,}}}diff --git a/crates/unfurl/src/domain/url_parsers.rs b/crates/unfurl/src/domain/url_parsers.rsindex 2bee51ca68..70f431ccb5 100644--- a/crates/unfurl/src/domain/url_parsers.rs+++ b/crates/unfurl/src/domain/url_parsers.rs@@ -1,16 +1,40 @@//! Custom URL parsers for services that embed document titles in their URLs-//! rather than in their HTML metadata.+//! rather than in their HTML metadata, and for services that support+//! iframe-embeddable content (video players, etc.).use url::Url;+/// The type of embeddable content.+#[derive(Debug, Clone, PartialEq, Eq)]+pub enum EmbedType {+ /// Video content (Loom, Supercut).+ Video,+}++/// Information about embeddable content for a URL.+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct EmbedInfo {+ /// The type of embeddable content.+ pub embed_type: EmbedType,+ /// The URL to use in an iframe for embedding.+ pub embed_url: String,+}++/// Validates that the hostname matches a provider domain exactly or is a+/// subdomain of it. Rejects lookalike domains (e.g. `loom.com.evil.example`).+fn is_valid_provider_host(host: &str, provider_domain: &str) -> bool {+ host == provider_domain || host.ends_with(&format!(".{}", provider_domain))+}+/// Parses Notion URLs to extract document titles/// Supports formats like:/// - notion.so/workspace/Title-With-Dashes-uuid/// - notion.so/Title-With-Dashes-uuidpub fn parse_notion_title(url: &str) -> Option<String> {let parsed_url = Url::parse(url).ok()?;+ let host = parsed_url.host_str()?;- if !parsed_url.host_str()?.contains("notion.so") {+ if !is_valid_provider_host(host, "notion.so") {return None;}@@ -49,8 +73,9 @@ pub fn parse_notion_title(url: &str) -> Option<String> {/// - figma.com/design/file-id/Title-With-Dashes?...pub fn parse_figma_title(url: &str) -> Option<String> {let parsed_url = Url::parse(url).ok()?;+ let host = parsed_url.host_str()?;- if !parsed_url.host_str()?.contains("figma.com") {+ if !is_valid_provider_host(host, "figma.com") {return None;}@@ -79,8 +104,9 @@ pub fn parse_figma_title(url: &str) -> Option<String> {/// - linear.app/team/issue/ticket-id/title-with-dashespub fn parse_linear_title(url: &str) -> Option<String> {let parsed_url = Url::parse(url).ok()?;+ let host = parsed_url.host_str()?;- if !parsed_url.host_str()?.contains("linear.app") {+ if !is_valid_provider_host(host, "linear.app") {return None;}@@ -104,33 +130,122 @@ pub fn parse_linear_title(url: &str) -> Option<String> {None}+/// Parses Supercut share URLs to generate embed URLs.+///+/// Supercut share URLs follow the pattern:+/// - `supercut.ai/share/{workspace}/{video_id}`+///+/// The embed URL uses the format:+/// - `supercut.ai/embed/{workspace}/{video_id}`+pub fn parse_supercut_embed(url: &str) -> Option<EmbedInfo> {+ let parsed_url = Url::parse(url).ok()?;+ let host = parsed_url.host_str()?;++ if !is_valid_provider_host(host, "supercut.ai") {+ return None;+ }++ let path = parsed_url.path();+ let segments: Vec<&str> = path.split('/').filter(|s| !s.is_empty()).collect();++ // Match /share/{workspace}/{video_id}+ if segments.len() >= 3 && segments[0] == "share" {+ let workspace = segments[1];+ let video_id = segments[2];++ let embed_url = format!("https://supercut.ai/embed/{}/{}", workspace, video_id);+ return Some(EmbedInfo {+ embed_type: EmbedType::Video,+ embed_url,+ });+ }++ None+}++/// Parses Loom share URLs to generate embed URLs.+///+/// Loom share URLs follow the pattern:+/// - `loom.com/share/{video_id}`+/// - `www.loom.com/share/{video_id}`+///+/// The embed URL uses the format:+/// - `loom.com/embed/{video_id}`+pub fn parse_loom_embed(url: &str) -> Option<EmbedInfo> {+ let parsed_url = Url::parse(url).ok()?;+ let host = parsed_url.host_str()?;++ if !is_valid_provider_host(host, "loom.com") {+ return None;+ }++ let path = parsed_url.path();+ let segments: Vec<&str> = path.split('/').filter(|s| !s.is_empty()).collect();++ // Match /share/{video_id}+ if segments.len() >= 2 && segments[0] == "share" {+ let video_id = segments[1];++ let embed_url = format!("https://www.loom.com/embed/{}", video_id);+ return Some(EmbedInfo {+ embed_type: EmbedType::Video,+ embed_url,+ });+ }++ None+}++/// Attempts to parse embed information from the URL for services that support+/// iframe embedding (Loom, Supercut, etc.).+pub fn parse_embed_info(url: &str) -> Option<EmbedInfo> {+ if let Some(info) = parse_supercut_embed(url) {+ return Some(info);+ }++ if let Some(info) = parse_loom_embed(url) {+ return Some(info);+ }++ None+}+/// Attempts to parse a title from the URL using custom parsers for known services./// Returns the service name as fallback if parsing fails on a recognized host.pub fn parse_custom_title(url: &str) -> Option<String> {let parsed_url = Url::parse(url).ok()?;let host = parsed_url.host_str()?;- if host.contains("notion.so") {+ if is_valid_provider_host(host, "notion.so") {if let Some(title) = parse_notion_title(url) {return Some(title);}return Some("Notion".to_string());}- if host.contains("figma.com") {+ if is_valid_provider_host(host, "figma.com") {if let Some(title) = parse_figma_title(url) {return Some(title);}return Some("Figma".to_string());}- if host.contains("linear.app") {+ if is_valid_provider_host(host, "linear.app") {if let Some(title) = parse_linear_title(url) {return Some(title);}return Some("Linear".to_string());}+ // For video services, return a fallback title.+ if is_valid_provider_host(host, "supercut.ai") {+ return Some("Supercut".to_string());+ }++ if is_valid_provider_host(host, "loom.com") {+ return Some("Loom".to_string());+ }+None}@@ -214,6 +329,117 @@ mod tests {parse_custom_title("https://linear.app"),Some("Linear".to_string()));+ assert_eq!(+ parse_custom_title("https://supercut.ai"),+ Some("Supercut".to_string())+ );+ assert_eq!(+ parse_custom_title("https://www.loom.com"),+ Some("Loom".to_string())+ );assert_eq!(parse_custom_title("https://google.com"), None);}++ #[test]+ fn test_supercut_embed_parsing() {+ // Standard share URL+ let url1 = "https://supercut.ai/share/onsteroids/zvAqfSVFnB7vUh71Sfqhq4";+ let result1 = parse_supercut_embed(url1);+ assert!(result1.is_some());+ let info1 = result1.unwrap();+ assert_eq!(info1.embed_type, EmbedType::Video);+ assert_eq!(+ info1.embed_url,+ "https://supercut.ai/embed/onsteroids/zvAqfSVFnB7vUh71Sfqhq4"+ );++ // Another workspace+ let url2 = "https://supercut.ai/share/float-labs/tOgpqhASaBW3FwM5v8NKTb";+ let result2 = parse_supercut_embed(url2);+ assert!(result2.is_some());+ let info2 = result2.unwrap();+ assert_eq!(+ info2.embed_url,+ "https://supercut.ai/embed/float-labs/tOgpqhASaBW3FwM5v8NKTb"+ );++ // Non-share URL should return None+ assert!(parse_supercut_embed("https://supercut.ai").is_none());+ assert!(parse_supercut_embed("https://supercut.ai/about").is_none());++ // Non-Supercut URL should return None+ assert!(parse_supercut_embed("https://google.com/share/abc/def").is_none());+ }++ #[test]+ fn test_loom_embed_parsing() {+ // Standard share URL+ let url1 = "https://www.loom.com/share/e5b8c04bca094dd8a5507925ab887002";+ let result1 = parse_loom_embed(url1);+ assert!(result1.is_some());+ let info1 = result1.unwrap();+ assert_eq!(info1.embed_type, EmbedType::Video);+ assert_eq!(+ info1.embed_url,+ "https://www.loom.com/embed/e5b8c04bca094dd8a5507925ab887002"+ );++ // Without www+ let url2 = "https://loom.com/share/abc123def456";+ let result2 = parse_loom_embed(url2);+ assert!(result2.is_some());+ let info2 = result2.unwrap();+ assert_eq!(info2.embed_url, "https://www.loom.com/embed/abc123def456");++ // Non-share URL should return None+ assert!(parse_loom_embed("https://www.loom.com").is_none());+ assert!(parse_loom_embed("https://www.loom.com/about").is_none());++ // Non-Loom URL should return None+ assert!(parse_loom_embed("https://google.com/share/abc").is_none());+ }++ #[test]+ fn test_parse_embed_info() {+ // Supercut+ let supercut_result = parse_embed_info("https://supercut.ai/share/workspace/video123");+ assert!(supercut_result.is_some());+ assert_eq!(supercut_result.unwrap().embed_type, EmbedType::Video);++ // Loom+ let loom_result = parse_embed_info("https://www.loom.com/share/video456");+ assert!(loom_result.is_some());+ assert_eq!(loom_result.unwrap().embed_type, EmbedType::Video);++ // Non-embeddable URL+ assert!(parse_embed_info("https://google.com").is_none());+ assert!(parse_embed_info("https://www.notion.so/page").is_none());+ }++ #[test]+ fn test_hostname_validation_rejects_lookalikes() {+ // Lookalike domains should be rejected (not substrings)+ assert!(parse_supercut_embed("https://supercut.ai.evil.example/share/ws/id").is_none());+ assert!(parse_supercut_embed("https://fake-supercut.ai/share/ws/id").is_none());+ assert!(parse_loom_embed("https://loom.com.evil.example/share/id").is_none());+ assert!(parse_loom_embed("https://fake-loom.com/share/id").is_none());++ // Valid subdomains should still work+ assert!(parse_supercut_embed("https://app.supercut.ai/share/ws/id").is_some());+ assert!(parse_loom_embed("https://app.loom.com/share/id").is_some());++ // Title fallbacks should also reject lookalikes+ assert!(parse_custom_title("https://supercut.ai.evil.example").is_none());+ assert!(parse_custom_title("https://loom.com.evil.example").is_none());++ // But valid providers should work+ assert_eq!(+ parse_custom_title("https://supercut.ai"),+ Some("Supercut".to_string())+ );+ assert_eq!(+ parse_custom_title("https://loom.com"),+ Some("Loom".to_string())+ );+ }}diff --git a/packages/sdk-docs/reference/generated/unfurl/types.gen/README.md b/packages/sdk-docs/reference/generated/unfurl/types.gen/README.mdindex 00d261dc1c..e2788b432f 100644--- a/packages/sdk-docs/reference/generated/unfurl/types.gen/README.md+++ b/packages/sdk-docs/reference/generated/unfurl/types.gen/README.md@@ -19,4 +19,5 @@- [GetUnfurlResponses](type-aliases/GetUnfurlResponses.md)- [ProxyParams](type-aliases/ProxyParams.md)- [ProxyRequestHandlerData](type-aliases/ProxyRequestHandlerData.md)+- [UnfurlEmbedType](type-aliases/UnfurlEmbedType.md)- [Vec](type-aliases/Vec.md)diff --git a/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/GetUnfurlResponse.md b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/GetUnfurlResponse.mdindex 8fecb5cfb6..0a909ee57b 100644--- a/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/GetUnfurlResponse.md+++ b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/GetUnfurlResponse.md@@ -1,6 +1,6 @@# Type Alias: GetUnfurlResponse-> **GetUnfurlResponse** = \{ `description?`: `string` \| `null`; `favicon_url?`: `string` \| `null`; `image_url?`: `string` \| `null`; `title`: `string`; `url`: `string`; \}+> **GetUnfurlResponse** = \{ `description?`: `string` \| `null`; `embed_type?`: [`UnfurlEmbedType`](UnfurlEmbedType.md); `embed_url?`: `string` \| `null`; `favicon_url?`: `string` \| `null`; `image_url?`: `string` \| `null`; `title`: `string`; `url`: `string`; \}Unfurl response for a single URL: the URL itself plus any metadata thatwas extracted from the page's `<head>` (title, description, image,@@ -11,6 +11,8 @@ favicon).| Property | Type | Description || ------ | ------ | ------ || <a id="property-description"></a> `description?` | `string` \| `null` | The page description (from `og:description`), if any. |+| <a id="property-embed_type"></a> `embed_type?` | [`UnfurlEmbedType`](UnfurlEmbedType.md) | The type of embeddable content, if the URL supports iframe embedding. |+| <a id="property-embed_url"></a> `embed_url?` | `string` \| `null` | The iframe-embeddable URL for services like Loom or Supercut. || <a id="property-favicon_url"></a> `favicon_url?` | `string` \| `null` | The page's favicon URL, if any. || <a id="property-image_url"></a> `image_url?` | `string` \| `null` | The page's preview image URL (from `og:image`), if any. || <a id="property-title"></a> `title` | `string` | The page title (from custom URL parser, Open Graph, or `<title>`). |diff --git a/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/UnfurlEmbedType.md b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/UnfurlEmbedType.mdnew file mode 100644index 0000000000..39342b5821--- /dev/null+++ b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/UnfurlEmbedType.md@@ -0,0 +1,5 @@+# Type Alias: UnfurlEmbedType++> **UnfurlEmbedType** = `"None"` \| `"Video"`++The type of embeddable content for services that support iframe embedding.diff --git a/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/Vec.md b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/Vec.mdindex 11c5ce5ef6..4b5df57974 100644--- a/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/Vec.md+++ b/packages/sdk-docs/reference/generated/unfurl/types.gen/type-aliases/Vec.md@@ -1,3 +1,3 @@# Type Alias: Vec-> **Vec** = (`null` \| \{ `description?`: `string` \| `null`; `favicon_url?`: `string` \| `null`; `image_url?`: `string` \| `null`; `title`: `string`; `url`: `string`; \})[]+> **Vec** = (`null` \| \{ `description?`: `string` \| `null`; `embed_type?`: [`UnfurlEmbedType`](UnfurlEmbedType.md); `embed_url?`: `string` \| `null`; `favicon_url?`: `string` \| `null`; `image_url?`: `string` \| `null`; `title`: `string`; `url`: `string`; \})[]diff --git a/packages/sdk/generated/unfurl/index.ts b/packages/sdk/generated/unfurl/index.tsindex 813c40d248..655685831c 100644--- a/packages/sdk/generated/unfurl/index.ts+++ b/packages/sdk/generated/unfurl/index.ts@@ -1,4 +1,4 @@// This file is auto-generated by @hey-api/openapi-tsexport { type Options, Sdk } from './sdk.gen';-export type { ClientOptions, GetUnfurlBulkBody, GetUnfurlBulkData, GetUnfurlBulkError, GetUnfurlBulkErrors, GetUnfurlBulkResponse, GetUnfurlBulkResponse2, GetUnfurlBulkResponses, GetUnfurlData, GetUnfurlError, GetUnfurlErrors, GetUnfurlQueryParams, GetUnfurlResponse, GetUnfurlResponse2, GetUnfurlResponses, ProxyParams, ProxyRequestHandlerData, Vec } from './types.gen';+export type { ClientOptions, GetUnfurlBulkBody, GetUnfurlBulkData, GetUnfurlBulkError, GetUnfurlBulkErrors, GetUnfurlBulkResponse, GetUnfurlBulkResponse2, GetUnfurlBulkResponses, GetUnfurlData, GetUnfurlError, GetUnfurlErrors, GetUnfurlQueryParams, GetUnfurlResponse, GetUnfurlResponse2, GetUnfurlResponses, ProxyParams, ProxyRequestHandlerData, UnfurlEmbedType, Vec } from './types.gen';diff --git a/packages/sdk/generated/unfurl/types.gen.ts b/packages/sdk/generated/unfurl/types.gen.tsindex bcff3865c8..51715eacd9 100644--- a/packages/sdk/generated/unfurl/types.gen.ts+++ b/packages/sdk/generated/unfurl/types.gen.ts@@ -32,6 +32,14 @@ export type GetUnfurlResponse = {* The page description (from `og:description`), if any.*/description?: string | null;+ /**+ * The type of embeddable content, if the URL supports iframe embedding.+ */+ embed_type?: UnfurlEmbedType;+ /**+ * The iframe-embeddable URL for services like Loom or Supercut.+ */+ embed_url?: string | null;/*** The page's favicon URL, if any.*/@@ -54,11 +62,24 @@ export type ProxyParams = {url: string;};+/**+ * The type of embeddable content for services that support iframe embedding.+ */+export type UnfurlEmbedType = 'None' | 'Video';+export type Vec = Array<null | {/*** The page description (from `og:description`), if any.*/description?: string | null;+ /**+ * The type of embeddable content, if the URL supports iframe embedding.+ */+ embed_type?: UnfurlEmbedType;+ /**+ * The iframe-embeddable URL for services like Loom or Supercut.+ */+ embed_url?: string | null;/*** The page's favicon URL, if any.*/diff --git a/packages/sdk/specs/unfurl.json b/packages/sdk/specs/unfurl.jsonindex 1b387844a3..ef38dab604 100644--- a/packages/sdk/specs/unfurl.json+++ b/packages/sdk/specs/unfurl.json@@ -179,6 +179,14 @@"type": ["string", "null"],"description": "The page description (from `og:description`), if any."},+ "embed_type": {+ "$ref": "#/components/schemas/UnfurlEmbedType",+ "description": "The type of embeddable content, if the URL supports iframe embedding."+ },+ "embed_url": {+ "type": ["string", "null"],+ "description": "The iframe-embeddable URL for services like Loom or Supercut."+ },"favicon_url": {"type": ["string", "null"],"description": "The page's favicon URL, if any."@@ -206,6 +214,11 @@}}},+ "UnfurlEmbedType": {+ "type": "string",+ "description": "The type of embeddable content for services that support iframe embedding.",+ "enum": ["None", "Video"]+ },"Vec": {"type": "array","items": {@@ -222,6 +235,14 @@"type": ["string", "null"],"description": "The page description (from `og:description`), if any."},+ "embed_type": {+ "$ref": "#/components/schemas/UnfurlEmbedType",+ "description": "The type of embeddable content, if the URL supports iframe embedding."+ },+ "embed_url": {+ "type": ["string", "null"],+ "description": "The iframe-embeddable URL for services like Loom or Supercut."+ },"favicon_url": {"type": ["string", "null"],"description": "The page's favicon URL, if any."diff --git a/services/document_cognition_service/src/service/get_chat.rs b/services/document_cognition_service/src/service/get_chat.rsindex 342e6776ed..592fb8a97b 100644--- a/services/document_cognition_service/src/service/get_chat.rs+++ b/services/document_cognition_service/src/service/get_chat.rs@@ -33,6 +33,8 @@ pub async fn get_chat(image_url: v.image_url,title: v.title,url: v.url,+ embed_type: Default::default(),+ embed_url: None,}).collect(),)diff --git a/services/unfurl_service/CUSTOM_PARSERS.md b/services/unfurl_service/CUSTOM_PARSERS.mdindex 475bf9a7ec..7db573e07f 100644--- a/services/unfurl_service/CUSTOM_PARSERS.md+++ b/services/unfurl_service/CUSTOM_PARSERS.md@@ -1,10 +1,12 @@# Custom URL Parsers-This document describes the custom URL parsing functionality added to the unfurl service to handle special cases where document titles are embedded in the URL structure rather than available in HTML metadata.+This document describes the custom URL parsing functionality added to the unfurl service to handle special cases where document titles are embedded in the URL structure rather than available in HTML metadata, and to support embeddable content (video players, etc.).## Supported Services-### Notion+### Title Parsing++#### Notion- **Pattern**: `notion.so/[workspace]/[title-with-dashes]-[uuid]` or `notion.so/[title-with-dashes]-[uuid]`- **Examples**:- `https://www.notion.so/macrocom/Enterprise-Product-Bottlenecks-5acb869109a747c1a1a92bbf1891ff2d` → "Enterprise Product Bottlenecks"@@ -12,20 +14,42 @@ This document describes the custom URL parsing functionality added to the unfurl- `https://www.notion.so/craft-ventures/Craft-Ventures-Operating-Playbooks-9db7bdccfc0f47be96076c122513691c` → "Craft Ventures Operating Playbooks"- **Fallback**: Returns "Notion" if URL parsing fails-### Figma+#### Figma- **Pattern**: `figma.com/design/[file-id]/[title-with-dashes]?...`- **Examples**:- `https://www.figma.com/design/Kf1Vep5riU3re2GO4E0q6b/Peter-Copy-of-Paper-Crowns?node-id=0-1&p=f&t=Z2dZh8AyxauKitCl-0` → "Peter Copy Of Paper Crowns"- `https://www.figma.com/design/VWgAP7zMauuWKkeS3CmWk3/AI-side-panel?node-id=0-1&p=f&t=SqdP6D2w2rZ5iSjV-0` → "AI Side Panel"- **Fallback**: Returns "Figma" if URL parsing fails-### Linear+#### Linear- **Pattern**: `linear.app/[team]/issue/[ticket-id]/[title-with-dashes]`- **Examples**:- `https://linear.app/macro-eng/issue/M-3586/ability-to-archive-emails` → "Ability To Archive Emails"- `https://linear.app/macro-eng/issue/M-3421/add-macro-permissions-to-jwt-token` → "Add Macro Permissions To Jwt Token"- **Fallback**: Returns "Linear" if URL parsing fails+### Video Embed Support++The unfurl service also supports embeddable video content for services like Loom and Supercut. When a share URL is detected, the response includes `embed_type: "Video"` and an `embed_url` that can be used in an iframe.++#### Supercut+- **Share URL Pattern**: `supercut.ai/share/[workspace]/[video-id]`+- **Embed URL**: `supercut.ai/embed/[workspace]/[video-id]`+- **Examples**:+ - `https://supercut.ai/share/onsteroids/zvAqfSVFnB7vUh71Sfqhq4` → embed: `https://supercut.ai/embed/onsteroids/zvAqfSVFnB7vUh71Sfqhq4`+- **Title Fallback**: Returns "Supercut" if URL parsing fails++#### Loom+- **Share URL Pattern**: `loom.com/share/[video-id]` or `www.loom.com/share/[video-id]`+- **Embed URL**: `www.loom.com/embed/[video-id]`+- **Examples**:+ - `https://www.loom.com/share/e5b8c04bca094dd8a5507925ab887002` → embed: `https://www.loom.com/embed/e5b8c04bca094dd8a5507925ab887002`+- **Title Fallback**: Returns "Loom" if URL parsing fails++#### Frontend Rendering++When the frontend receives an unfurl response with `embed_type: "Video"` and `embed_url`, it renders an embedded video player using an iframe instead of a standard link preview card. The video player is shown on hover in the `LinkHoverCard` component.+## Implementation Details### Files Added/Modified@@ -46,13 +70,17 @@ This document describes the custom URL parsing functionality added to the unfurl### Function Hierarchy```-GetUnfurlResponse::get_title()-├── parse_custom_title()-│ ├── parse_notion_title() → Some("Parsed Title") | None-│ ├── parse_figma_title() → Some("Parsed Title") | None-│ ├── parse_linear_title() → Some("Parsed Title") | None-│ └── Fallback to service name (e.g., "Notion", "Figma", "Linear")-└── Original metadata extraction (if custom parsing returns None)+GetUnfurlResponse::new()+├── get_title() → title string+│ ├── parse_custom_title()+│ │ ├── parse_notion_title() → Some("Parsed Title") | None+│ │ ├── parse_figma_title() → Some("Parsed Title") | None+│ │ ├── parse_linear_title() → Some("Parsed Title") | None+│ │ └── Fallback to service name (e.g., "Notion", "Figma", "Linear", "Supercut", "Loom")+│ └── Original metadata extraction (if custom parsing returns None)+└── parse_embed_info() → embed_type, embed_url+ ├── parse_supercut_embed() → Some(EmbedInfo) | None+ └── parse_loom_embed() → Some(EmbedInfo) | None```## Testing@@ -82,6 +110,12 @@ curl 'http://localhost:8080/unfurl?url=https://www.figma.com/design/Kf1Vep5riU3r# Test Linear URLcurl 'http://localhost:8080/unfurl?url=https://linear.app/macro-eng/issue/M-3586/ability-to-archive-emails'+# Test Supercut URL (returns embed_type and embed_url)+curl 'http://localhost:8080/unfurl?url=https://supercut.ai/share/onsteroids/zvAqfSVFnB7vUh71Sfqhq4'++# Test Loom URL (returns embed_type and embed_url)+curl 'http://localhost:8080/unfurl?url=https://www.loom.com/share/e5b8c04bca094dd8a5507925ab887002'+# Test bulk processingjust bulk-link-test```