Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Upgraded `nanoid` to `^3.3.18`. [#1557](https://github.com/sourcebot-dev/sourcebot/pull/1557)
- Upgraded `dompurify` to `^3.4.13`. [#1556](https://github.com/sourcebot-dev/sourcebot/pull/1556)
- Upgraded `mermaid` to `^11.16.1`. [#1555](https://github.com/sourcebot-dev/sourcebot/pull/1555)
- [EE] Fixed Ask Sourcebot file reference citations for repositories whose code host URL includes a port. [#1565](https://github.com/sourcebot-dev/sourcebot/pull/1565)

## [5.1.5] - 2026-07-31

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function remarkReferencesPlugin() {
return function (tree: Nodes) {
findAndReplace(tree, [
FILE_REFERENCE_REGEX,
(_, repo: string, fileName: string, startLine?: string, endLine?: string) => {
(_, repo: string, _port: string | undefined, fileName: string, startLine?: string, endLine?: string) => {
// Create display text
let displayText = fileName.split('/').pop() ?? fileName;

Expand Down Expand Up @@ -290,4 +290,4 @@ const MarkdownRendererComponent = forwardRef<HTMLDivElement, MarkdownRendererPro

MarkdownRendererComponent.displayName = 'MarkdownRenderer';

export const MarkdownRenderer = memo(MarkdownRendererComponent, isEqual);
export const MarkdownRenderer = memo(MarkdownRendererComponent, isEqual);
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const getFileSourcesFromText = (text: string): FileSource[] => {
FILE_REFERENCE_REGEX.lastIndex = 0;
let match: RegExpExecArray | null;
while ((match = FILE_REFERENCE_REGEX.exec(text)) !== null) {
const [, repo, path] = match;
const [, repo, , path] = match;
if (!repo || !path) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const parseInlineInstructions = (text: string): Descendant[] => {
FILE_REFERENCE_REGEX.lastIndex = 0;
let match: RegExpExecArray | null;
while ((match = FILE_REFERENCE_REGEX.exec(text)) !== null) {
const [rawReference, repo, path] = match;
const [rawReference, repo, , path] = match;
if (!repo || !path) {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/web/src/ee/features/chat/useExtractPanelItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const useExtractPanelItems = (
const combined = new RegExp(`${MERMAID_BLOCK_REGEX.source}|${FILE_REFERENCE_REGEX.source}`, 'g');
let match: RegExpExecArray | null;
while ((match = combined.exec(text)) !== null) {
// match[1]: mermaid body. match[2..5]: file reference repo/path/start/end.
// match[1]: mermaid body. match[2..6]: file reference repo/port/path/start/end.
if (match[1] !== undefined) {
const code = match[1].trim();
if (!code) {
Expand All @@ -85,8 +85,8 @@ export const useExtractPanelItems = (
const diagramIndex = diagrams.length;
diagrams.push(diagram);
orderedItems.push({ kind: 'diagram', diagram, diagramIndex });
} else if (match[2] !== undefined && match[3] !== undefined) {
const reference = createFileReference({ repo: match[2], path: match[3], startLine: match[4], endLine: match[5] });
} else if (match[2] !== undefined && match[4] !== undefined) {
const reference = createFileReference({ repo: match[2], path: match[4], startLine: match[5], endLine: match[6] });
const source = tryResolveFileReference(reference, referencedFileSources);
if (!source) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/ee/features/chat/useExtractReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useExtractReferences = (part?: TextUIPart) => {

let match;
while ((match = FILE_REFERENCE_REGEX.exec(content ?? '')) !== null && match !== null) {
const [_, repo, fileName, startLine, endLine] = match;
const [, repo, , fileName, startLine, endLine] = match;

const fileReference = createFileReference({
repo: repo,
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/features/chat/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const FILE_REFERENCE_PREFIX = '@file:';
export const FILE_REFERENCE_REGEX = new RegExp(
// @file:{repoName::fileName:startLine-endLine}
`${FILE_REFERENCE_PREFIX}\\{([^:}]+)::([^:}]+)(?::(\\d+)(?:-(\\d+))?)?\\}`,
`${FILE_REFERENCE_PREFIX}\\{([^:}]+(:\\d+)?[^:}]*)::([^:}]+)(?::(\\d+)(?:-(\\d+))?)?\\}`,
'g'
);

Expand Down
21 changes: 21 additions & 0 deletions packages/web/src/features/chat/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@ test('fileReferenceToString matches FILE_REFERENCE_REGEX', () => {
}))).toBe(true);
});

test('fileReferenceToString matches FILE_REFERENCE_REGEX for repos with ports', () => {
const reference = fileReferenceToString({
repo: 'git.example.com:8080/org/repo',
path: 'auth.ts',
range: {
startLine: 45,
endLine: 60,
},
});

FILE_REFERENCE_REGEX.lastIndex = 0;
const match = FILE_REFERENCE_REGEX.exec(reference);

expect(match).not.toBeNull();
expect(match?.[1]).toBe('git.example.com:8080/org/repo');
expect(match?.[2]).toBe(':8080');
expect(match?.[3]).toBe('auth.ts');
expect(match?.[4]).toBe('45');
expect(match?.[5]).toBe('60');
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

test('slateContentToString serializes command mentions as literal slash commands', () => {
const children = [{
type: 'paragraph',
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/features/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const createFileReference = ({ repo, path, startLine, endLine }: { repo:
export const convertLLMOutputToPortableMarkdown = (text: string, baseUrl: string, sources: FileSource[]): string => {
return text
.replace(ANSWER_TAG, '')
.replace(FILE_REFERENCE_REGEX, (_, repo, fileName, startLine, endLine) => {
.replace(FILE_REFERENCE_REGEX, (_, repo, _port, fileName, startLine, endLine) => {
const reference = createFileReference({
repo,
path: fileName,
Expand Down
Loading