99
1010import { configuredHostedAppUrl } from "../../hostedPairing" ;
1111import { useThreadRefs , useThreadShell } from "../../state/entities" ;
12+ import { useEnvironmentIdentities } from "../../state/environments" ;
1213import { orchestrationEnvironment } from "../../state/orchestration" ;
1314import { useEnvironmentQuery } from "../../state/query" ;
1415import { UnresolvedChip } from "../contextChipParts" ;
@@ -23,8 +24,12 @@ export function MarkdownThreadLink(props: {
2324 const candidates = threadLinkCandidates ( props . link , props . environmentId ) ;
2425 const writtenRef = candidates [ 0 ] ! ;
2526 const written = useThreadShell ( writtenRef ) ;
27+ // A linked machine's threads are reachable only through its server, not from this client.
28+ const reachable = useEnvironmentIdentities ( ) . some (
29+ ( environment ) => environment . environmentId === writtenRef . environmentId ,
30+ ) ;
2631 const lookup = useEnvironmentQuery (
27- written === null
32+ written === null && reachable
2833 ? orchestrationEnvironment . threadLinkMetadata ( {
2934 environmentId : writtenRef . environmentId ,
3035 input : { threadIds : candidates . map ( ( ref ) => ref . threadId ) } ,
@@ -39,7 +44,7 @@ export function MarkdownThreadLink(props: {
3944 const metadata = lookup . data ?. [ ref . threadId ] ;
4045 return metadata ? [ { ref, metadata } ] : [ ] ;
4146 } ) [ 0 ] ?? null ) ;
42- const missing = target === null && settled ;
47+ const missing = target === null && ( settled || ! reachable ) ;
4348 const guess = missing && props . link . environmentId === null ;
4449 const refs = useThreadRefs ( guess ) ;
4550 const remoteRef = guess
0 commit comments