Skip to content

Commit c575acd

Browse files
committed
fix(clients): retain scoped links for ordinary thread ids
1 parent 4f7a4d5 commit c575acd

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎apps/mobile/src/lib/composerContextClipboard.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ describe("mobile context clipboard imports", () => {
247247
),
248248
).toBe(true);
249249
expect(result!.text).toMatch(
250-
/^Compare these findings: \[Remote discussion\]\(https:\/\/app\.t3\.codes\/threads\/source\/foreign-thread\) .* before changing anything\.$/,
250+
/^Compare these findings: \[Remote discussion\]\(t3-thread:\/\/v2\/source\/foreign-thread\) .* before changing anything\.$/,
251251
);
252252

253253
const restoreHistory = createComposerContextHistory();

‎apps/web/src/components/chat/useComposerContextImport.browser.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ it.each([false, true])(
250250
});
251251
expect(Object.fromEntries(remapped)).toEqual({
252252
[unlinked.contextId]: {
253-
markdown: "[Thread remote](https://app.t3.codes/threads/unlinked-source/remote)",
253+
markdown: "[Thread remote](t3-thread://v2/unlinked-source/remote)",
254254
},
255255
[linked.contextId]: linked.contextId,
256256
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ describe("threadLinkContextReferences", () => {
521521
() => "Here",
522522
);
523523
expect(pasted.records).toEqual([copied, threadContextRecord(thread("env-9", "t9"), "Here")]);
524-
for (const threadId of ["a)b", "a b", "a>b", "a%29b"]) {
524+
for (const threadId of ["a)b", "a b", "a>b", "a%29b", ".", ".."]) {
525525
const record = threadContextRecord(thread("env-1", threadId), "Copied title");
526526
expect(
527527
threadLinkContextReferences(unreadableThreadContextLink(record), [], () => undefined)

‎packages/shared/src/composerContextReferences.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import {
1010
type ThreadContextRecord,
1111
} from "@t3tools/contracts";
1212

13-
import { formatHostedThreadLink, replaceThreadLinks, threadLinkCandidates } from "./threadLinks.ts";
13+
import {
14+
formatHostedThreadLink,
15+
formatThreadLink,
16+
replaceThreadLinks,
17+
threadLinkCandidates,
18+
} from "./threadLinks.ts";
1419

1520
const CONTEXT_PROTOCOL = "t3-context:";
1621
const COMPOSER_CONTEXT_HREF_PREFIX = `${CONTEXT_PROTOCOL}//v1/`;
@@ -429,7 +434,9 @@ export function threadContextsOutsideEnvironment(input: {
429434

430435
/** A thread this agent can't read stays a link naming its machine, so the ids survive without attaching it. */
431436
export function unreadableThreadContextLink(record: ThreadContextRecord): string {
432-
return formatHostedThreadLink(record, record.title);
437+
return /[\s()<>\\]/.test(`${record.environmentId}/${record.threadId}`)
438+
? formatHostedThreadLink(record, record.title)
439+
: formatThreadLink(record, record.title);
433440
}
434441

435442
export function remapComposerContextAttachments(

0 commit comments

Comments
 (0)