MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / createUIMessage

Function createUIMessage

packages/web/src/features/chat/utils.ts:190–226  ·  view source on GitHub ↗
(text: string, mentions: MentionData[], selectedSearchScopes: SearchScope[], disabledMcpServerIds: string[] = [])

Source from the content-addressed store, hash-verified

188}
189
190export const createUIMessage = (text: string, mentions: MentionData[], selectedSearchScopes: SearchScope[], disabledMcpServerIds: string[] = []): CreateUIMessage<SBChatMessage> => {
191 // Converts applicable mentions into sources.
192 const sources: Source[] = mentions
193 .map((mention) => {
194 if (mention.type === 'file') {
195 const fileSource: FileSource = {
196 type: 'file',
197 path: mention.path,
198 repo: mention.repo,
199 name: mention.name,
200 revision: mention.revision,
201 }
202 return fileSource;
203 }
204
205 return undefined;
206 })
207 .filter((source) => source !== undefined);
208
209 return {
210 role: 'user',
211 parts: [
212 {
213 type: 'text',
214 text,
215 },
216 ...sources.map((data) => ({
217 type: 'data-source',
218 data,
219 })) as UIMessagePart<{ source: Source }, SBChatMessageToolTypes>[],
220 ],
221 metadata: {
222 selectedSearchScopes,
223 disabledMcpServerIds,
224 },
225 }
226}
227
228export const getFileReferenceId = ({ repo, path, range }: Omit<FileReference, 'type' | 'id'>) => {
229 return `file-reference-${repo}::${path}${range ? `-${range.startLine}-${range.endLine}` : ''}`;

Callers 3

utils.test.tsFile · 0.90
useCreateNewChatThreadFunction · 0.90
ChatThreadFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected