Skip to content

Commit 0f9b759

Browse files
EtanHeyclaude
andcommitted
fix(mobile): thread links written as [label](<t3-thread://…>) no longer turn into broken text
T3's own link values come wrapped in angle brackets, and agents write them as labeled links. The relabel pattern only accepted a bare destination, so it matched the inner autolink and left the label and parentheses as text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8b74a69 commit 0f9b759

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/shared/src/threadLinks.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,23 @@ describe("thread links", () => {
9595
const title = titlesIn({ local: { t1: "Here" }, there: { t1: "There" } });
9696
expect(
9797
relabelThreadLinks(
98-
"<t3-thread://v2/there/t1> and [old](t3-thread://v2/local/t1)",
98+
"<t3-thread://v2/there/t1> and [old](t3-thread://v2/local/t1) and [old](<t3-thread://v2/local/t1>)",
9999
local,
100100
title,
101101
),
102-
).toBe("[There](t3-thread://v2/there/t1) and [Here](t3-thread://v2/local/t1)");
102+
).toBe(
103+
"[There](t3-thread://v2/there/t1) and [Here](t3-thread://v2/local/t1) and [Here](t3-thread://v2/local/t1)",
104+
);
103105
});
104106

105107
it("turns a v2 link it cannot resolve into plain text, never the raw link", () => {
106108
expect(
107109
relabelThreadLinks(
108-
"<t3-thread://v2/there/t1>, <t3-thread://v2/local/t1>, [Old title](t3-thread://v2/there/t1)",
110+
"<t3-thread://v2/there/t1>, <t3-thread://v2/local/t1>, [Old title](t3-thread://v2/there/t1), [Kept](<t3-thread://v2/local/t1>)",
109111
local,
110112
() => undefined,
111113
),
112-
).toBe("Thread on another machine, Thread no longer available, Old title");
114+
).toBe("Thread on another machine, Thread no longer available, Old title, Kept");
113115
expect(relabelThreadLinks("[Old](t3-thread://v1/t1)", local, () => undefined)).toBe(
114116
"[Old](t3-thread://v1/t1)",
115117
);

‎packages/shared/src/threadLinks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const V1_PREFIX = `${THREAD_LINK_PROTOCOL}://v1/`;
77
const V2_PREFIX = `${THREAD_LINK_PROTOCOL}://v2/`;
88
// Code comes first in the alternation so a link written inside a code span or fence is skipped.
99
const THREAD_LINK_OUTSIDE_CODE =
10-
/(?<fence>(`{3,}|~{3,})[\s\S]*?(?:\2|$))|(?<span>(`+)[^\n]*?\4)|\[(?<label>[^\]\n]*)\]\((?<href>t3-thread:\/\/v[12]\/[^\s)]+)\)|<(?<autolink>t3-thread:\/\/v[12]\/[^\s<>]+)>/g;
10+
/(?<fence>(`{3,}|~{3,})[\s\S]*?(?:\2|$))|(?<span>(`+)[^\n]*?\4)|\[(?<label>[^\]\n]*)\]\(<?(?<href>t3-thread:\/\/v[12]\/[^\s<>)]+)>?\)|<(?<autolink>t3-thread:\/\/v[12]\/[^\s<>]+)>/g;
1111

1212
const decodeThreadId = Schema.decodeUnknownOption(ThreadId);
1313
const decodeEnvironmentId = Schema.decodeUnknownOption(EnvironmentId);

0 commit comments

Comments
 (0)