Skip to content

Commit aec0fc7

Browse files
committed
Release v3.0.1: Add VFB report link generation and improved term linking
1 parent 8385b2d commit aec0fc7

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This file summarizes the release notes inferred from git tags (tag message/annot
44

55
---
66

7+
## v3.0.1
8+
- Release v3.0.1: Add VFB report link generation and improved term linking
9+
710
## v3.0.0
811
- Release v3.0.0
912

app/api/chat/route.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,12 +621,14 @@ function replaceTermsWithLinks(text) {
621621
return `\x00LINK${allLinks.length - 1}\x00`
622622
})
623623

624+
const REPORT_BASE = 'https://virtualflybrain.org/reports/'
625+
624626
for (const term of sortedTerms) {
625627
const id = lookupCache[term]
626628
const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
627629
const regex = new RegExp(`\\b${escaped}\\b`, 'gi')
628630
result = result.replace(regex, (match) => {
629-
const link = `[${match}](${id})`
631+
const link = `[${match}](${REPORT_BASE + encodeURIComponent(id)})`
630632
allLinks.push(link)
631633
return `\x00LINK${allLinks.length - 1}\x00`
632634
})

app/page.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ const ChatMessage = memo(function ChatMessage({ msg, markdownComponents }) {
3737
className="message-content"
3838
style={msg.role === 'reasoning' ? { fontSize: '0.85em', fontStyle: 'italic', color: '#999' } : {}}
3939
>
40-
<ReactMarkdown components={markdownComponents}>
40+
<ReactMarkdown
41+
components={{
42+
...markdownComponents,
43+
a: ({ node, ...props }) => <a {...props} target="_blank" rel="noreferrer" />
44+
}}
45+
>
4146
{msg.content}
4247
</ReactMarkdown>
4348
</div>
@@ -82,11 +87,19 @@ export default function Home() {
8287
const chatEndRef = useRef(null)
8388
const msgIdRef = useRef(0) // stable, incrementing message ID
8489

90+
// Helper: inject VFB term links into responses, so IDs like FBbt_00003748 or VFB_00102107
91+
// become clickable links to the corresponding Virtual Fly Brain report page.
92+
const linkifyVfbTerms = (text) => {
93+
if (!text) return text
94+
// Avoid double-linking IDs that are already inside markdown links.
95+
return text.replace(/(?<!\[)(?<!\]\()(\b(FBbt_\d{8}|VFB_\d{8})\b)/g, '[$1](https://virtualflybrain.org/reports/$1)')
96+
}
97+
8598
// Helper: create a message object with a stable unique id
8699
const makeMsg = useCallback((role, content, extras = {}) => ({
87100
id: ++msgIdRef.current,
88101
role,
89-
content,
102+
content: role !== 'user' ? linkifyVfbTerms(content) : content,
90103
...extras
91104
}), [])
92105

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vfb-chat-client",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

0 commit comments

Comments
 (0)