# Files changed · PR \#22237 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/22237/diffs)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

[fix\(mobile\): thread links in chat render as chips](https://git.cafe/pingdotgg/t3code/pull/22237.md)

Version: 51

Head commit: ad7e4fb78cbde18558d673069bfd41117388d89e

Base commit: ecfe4f7955bd826a4d465aa52200ea4354a0cb7f

Comparison base: ecfe4f7955bd826a4d465aa52200ea4354a0cb7f

Showing up to 20 entries from this revision. If the pull request changes, reopen the first page before continuing.

## apps/mobile/src/features/threads/ThreadFeed.tsx

Status: modified; +5; −1

```diff
@@ -4,8 +4,11 @@
 import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-width";
 import { ThreadMarkdownVideo, ThreadMediaVisibleContext } from "./ThreadMarkdownVideo";
 import { useMarkdownImageSource } from "../../native/useMarkdownImageSource";
-import { enrichedContextLinkCustomization } from "../../native/useEnrichedLinkVariants";
 import {
+  enrichedContextLinkCustomization,
+  enrichedThreadLinkCustomization,
+} from "../../native/useEnrichedLinkVariants";
+import {
   enrichedSkillDisplayName,
   enrichedSkillInstructionsPath,
   enrichedSkillReference,
@@ -1977,6 +1980,7 @@
   });
   const markdownLinkHandlers: MarkdownLinkHandlers = {
     onLinkPress: onMarkdownLinkPress,
+    linkCustomization: enrichedThreadLinkCustomization,
     onImagePress: (href) => onMarkdownLinkPress(href, true),
     resolveImageSource,
     fileContextMenu: (href) => {
```

## apps/mobile/src/lib/enrichedLinkPresentation.test.ts

Status: modified; +15; −0

```diff
@@ -2,6 +2,7 @@
 import {
   enrichedLinkVariantPattern,
   enrichedSkillLinkRegex,
+  enrichedThreadLinkPresentation,
   ENRICHED_INLINE_FILE_LINK_REGEX,
 } from "./enrichedLinkPresentation";
 
@@ -46,4 +47,18 @@
     expect(pattern.test(`${url}/child`)).toBe(false);
     expect(pattern.test("file:///workspace/app1Xtsx?line=34")).toBe(false);
   });
+
+  it("presents thread links as thread chips and leaves other links alone", () => {
+    expect(enrichedThreadLinkPresentation("t3-thread://v1/thread%3Aproject%3A1")).toEqual({
+      accent: "#009c96",
+      icon: { kind: "chip", name: "messages-square" },
+    });
+    for (const href of [
+      "https://github.com/example/repo/pull/7",
+      "https://example.com",
+      "t3-context://v1/thread/thread_1",
+    ]) {
+      expect(enrichedThreadLinkPresentation(href), href).toBeUndefined();
+    }
+  });
 });
```

## apps/mobile/src/lib/enrichedLinkPresentation.ts

Status: modified; +12; −0

```diff
@@ -9,6 +9,7 @@
 } from "./composerChipPresentation";
 import type { SelectableMarkdownSkill } from "../native/SelectableMarkdownText.types";
 import { parseComposerContextHref } from "@t3tools/shared/composerContextReferences";
+import { parseThreadLinkHref } from "@t3tools/shared/threadLinks";
 
 export function enrichedContextLinkPresentation(
   href: string,
@@ -29,6 +30,17 @@
   };
 }
 
+export function enrichedThreadLinkPresentation(
+  href: string,
+): { accent?: string; icon: ContextChipIconRef } | undefined {
+  if (!parseThreadLinkHref(href)) return undefined;
+  const presentation = contextChipPresentation("thread");
+  return {
+    ...(presentation.accent ? { accent: presentation.accent } : {}),
+    icon: contextChipIcon(presentation, ""),
+  };
+}
+
 export function enrichedLinkVariantPattern(url: string) {
   return `^${url.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
 }
```

## apps/mobile/src/native/useEnrichedLinkVariants.ts

Status: modified; +18; −8

```diff
@@ -22,21 +22,31 @@
   enrichedLinkVariantPattern,
   enrichedSkillDisplayName,
   enrichedSkillReference,
+  enrichedThreadLinkPresentation,
 } from "../lib/enrichedLinkPresentation";
 
-export function enrichedContextLinkCustomization(
+function chipCustomization(
+  chip: ReturnType<typeof enrichedContextLinkPresentation>,
-  href: string,
-  records?: ReadonlyArray<ComposerContextRecord>,
 ): MarkdownLinkCustomization | undefined {
+  if (!chip) return undefined;
-  const context = enrichedContextLinkPresentation(href, records);
-  if (!context) return undefined;
   return {
-    label: context.label,
-    icon: contextChipIconSource(context.icon),
+    label: chip.label,
-    chip: { accent: context.accent, tintsIcon: context.icon.kind === "chip" },
+    icon: contextChipIconSource(chip.icon),
+    chip: { accent: chip.accent, tintsIcon: chip.icon.kind === "chip" },
   };
 }
 
+export function enrichedContextLinkCustomization(
+  href: string,
+  records?: ReadonlyArray<ComposerContextRecord>,
+) {
+  return chipCustomization(enrichedContextLinkPresentation(href, records));
+}
+
+export function enrichedThreadLinkCustomization(href: string) {
+  return chipCustomization(enrichedThreadLinkPresentation(href));
+}
+
 function presentation(
   url: string,
   props: Pick<SelectableMarkdownTextProps, "linkCustomization" | "skills" | "textStyle">,
```
