Merge branch 'Highlight-Response'

This commit is contained in:
Woody 2026-05-15 11:23:02 +08:00
commit 29b4713f22
10 changed files with 229 additions and 384 deletions

View File

@ -48,6 +48,8 @@ _SEED_GENERATE_PER_SUBQ = (
"Copy the exact bracket labels shown in the document chunks — " "Copy the exact bracket labels shown in the document chunks — "
"do not modify filenames or add/remove extensions.\n" "do not modify filenames or add/remove extensions.\n"
"Place the citation at the end of each bullet point.\n" "Place the citation at the end of each bullet point.\n"
"For monetary figures (e.g., HK$1,000,000), percentages (e.g., 35%), key statistics, "
"and dates (e.g., 1 January 2024, 2023), wrap them in ==double equals markers== for highlighting.\n"
"{context_sections}\n\n" "{context_sections}\n\n"
"Answer:" "Answer:"
) )

View File

@ -33,6 +33,7 @@
"jsdom": "^20.0.3", "jsdom": "^20.0.3",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.1.6", "typescript": "^5.1.6",
"vite": "^4.4.0",
"vitest": "^0.34.3" "vitest": "^0.34.3"
}, },
"pnpm": { "pnpm": {

View File

@ -62,7 +62,7 @@ importers:
version: 18.3.7(@types/react@18.3.28) version: 18.3.7(@types/react@18.3.28)
'@vitejs/plugin-react': '@vitejs/plugin-react':
specifier: ^4.0.0 specifier: ^4.0.0
version: 4.7.0(vite@5.4.21(@types/node@25.7.0)) version: 4.7.0(vite@4.5.14(@types/node@25.7.0))
jsdom: jsdom:
specifier: ^20.0.3 specifier: ^20.0.3
version: 20.0.3 version: 20.0.3
@ -72,6 +72,9 @@ importers:
typescript: typescript:
specifier: ^5.1.6 specifier: ^5.1.6
version: 5.9.3 version: 5.9.3
vite:
specifier: ^4.4.0
version: 4.5.14(@types/node@25.7.0)
vitest: vitest:
specifier: ^0.34.3 specifier: ^0.34.3
version: 0.34.6(jsdom@20.0.3) version: 0.34.6(jsdom@20.0.3)
@ -176,140 +179,134 @@ packages:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'} engines: {node: '>=12'}
'@esbuild/aix-ppc64@0.21.5': '@esbuild/android-arm64@0.18.20':
resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [aix]
'@esbuild/android-arm64@0.21.5':
resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
'@esbuild/android-arm@0.21.5': '@esbuild/android-arm@0.18.20':
resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm] cpu: [arm]
os: [android] os: [android]
'@esbuild/android-x64@0.21.5': '@esbuild/android-x64@0.18.20':
resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [android] os: [android]
'@esbuild/darwin-arm64@0.21.5': '@esbuild/darwin-arm64@0.18.20':
resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
'@esbuild/darwin-x64@0.21.5': '@esbuild/darwin-x64@0.18.20':
resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
'@esbuild/freebsd-arm64@0.21.5': '@esbuild/freebsd-arm64@0.18.20':
resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm64] cpu: [arm64]
os: [freebsd] os: [freebsd]
'@esbuild/freebsd-x64@0.21.5': '@esbuild/freebsd-x64@0.18.20':
resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
'@esbuild/linux-arm64@0.21.5': '@esbuild/linux-arm64@0.18.20':
resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
'@esbuild/linux-arm@0.21.5': '@esbuild/linux-arm@0.18.20':
resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
'@esbuild/linux-ia32@0.21.5': '@esbuild/linux-ia32@0.18.20':
resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [ia32] cpu: [ia32]
os: [linux] os: [linux]
'@esbuild/linux-loong64@0.21.5': '@esbuild/linux-loong64@0.18.20':
resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [loong64] cpu: [loong64]
os: [linux] os: [linux]
'@esbuild/linux-mips64el@0.21.5': '@esbuild/linux-mips64el@0.18.20':
resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [mips64el] cpu: [mips64el]
os: [linux] os: [linux]
'@esbuild/linux-ppc64@0.21.5': '@esbuild/linux-ppc64@0.18.20':
resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [ppc64] cpu: [ppc64]
os: [linux] os: [linux]
'@esbuild/linux-riscv64@0.21.5': '@esbuild/linux-riscv64@0.18.20':
resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [riscv64] cpu: [riscv64]
os: [linux] os: [linux]
'@esbuild/linux-s390x@0.21.5': '@esbuild/linux-s390x@0.18.20':
resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [s390x] cpu: [s390x]
os: [linux] os: [linux]
'@esbuild/linux-x64@0.21.5': '@esbuild/linux-x64@0.18.20':
resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
'@esbuild/netbsd-x64@0.21.5': '@esbuild/netbsd-x64@0.18.20':
resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [netbsd] os: [netbsd]
'@esbuild/openbsd-x64@0.21.5': '@esbuild/openbsd-x64@0.18.20':
resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [openbsd] os: [openbsd]
'@esbuild/sunos-x64@0.21.5': '@esbuild/sunos-x64@0.18.20':
resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [sunos] os: [sunos]
'@esbuild/win32-arm64@0.21.5': '@esbuild/win32-arm64@0.18.20':
resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
'@esbuild/win32-ia32@0.21.5': '@esbuild/win32-ia32@0.18.20':
resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
'@esbuild/win32-x64@0.21.5': '@esbuild/win32-x64@0.18.20':
resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==}
engines: {node: '>=12'} engines: {node: '>=12'}
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
@ -451,144 +448,6 @@ packages:
'@rolldown/pluginutils@1.0.0-beta.27': '@rolldown/pluginutils@1.0.0-beta.27':
resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==} resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==}
'@rollup/rollup-android-arm-eabi@4.60.3':
resolution: {integrity: sha512-x35CNW/ANXG3hE/EZpRU8MXX1JDN86hBb2wMGAtltkz7pc6cxgjpy1OMMfDosOQ+2hWqIkag/fGok1Yady9nGw==}
cpu: [arm]
os: [android]
'@rollup/rollup-android-arm64@4.60.3':
resolution: {integrity: sha512-xw3xtkDApIOGayehp2+Rz4zimfkaX65r4t47iy+ymQB2G4iJCBBfj0ogVg5jpvjpn8UWn/+q9tprxleYeNp3Hw==}
cpu: [arm64]
os: [android]
'@rollup/rollup-darwin-arm64@4.60.3':
resolution: {integrity: sha512-vo6Y5Qfpx7/5EaamIwi0WqW2+zfiusVihKatLvtN1VFVy3D13uERk/6gZLU1UiHRL6fDXqj/ELIeVRGnvcTE1g==}
cpu: [arm64]
os: [darwin]
'@rollup/rollup-darwin-x64@4.60.3':
resolution: {integrity: sha512-D+0QGcZhBzTN82weOnsSlY7V7+RMmPuF1CkbxyMAGE8+ZHeUjyb76ZiWmBlCu//AQQONvxcqRbwZTajZKqjuOw==}
cpu: [x64]
os: [darwin]
'@rollup/rollup-freebsd-arm64@4.60.3':
resolution: {integrity: sha512-6HnvHCT7fDyj6R0Ph7A6x8dQS/S38MClRWeDLqc0MdfWkxjiu1HSDYrdPhqSILzjTIC/pnXbbJbo+ft+gy/9hQ==}
cpu: [arm64]
os: [freebsd]
'@rollup/rollup-freebsd-x64@4.60.3':
resolution: {integrity: sha512-KHLgC3WKlUYW3ShFKnnosZDOJ0xjg9zp7au3sIm2bs/tGBeC2ipmvRh/N7JKi0t9Ue20C0dpEshi8WUubg+cnA==}
cpu: [x64]
os: [freebsd]
'@rollup/rollup-linux-arm-gnueabihf@4.60.3':
resolution: {integrity: sha512-DV6fJoxEYWJOvaZIsok7KrYl0tPvga5OZ2yvKHNNYyk/2roMLqQAbGhr78EQ5YhHpnhLKJD3S1WFusAkmUuV5g==}
cpu: [arm]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.60.3':
resolution: {integrity: sha512-mQKoJAzvuOs6F+TZybQO4GOTSMUu7v0WdxEk24krQ/uUxXoPTtHjuaUuPmFhtBcM4K0ons8nrE3JyhTuCFtT/w==}
cpu: [arm]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.60.3':
resolution: {integrity: sha512-Whjj2qoiJ6+OOJMGptTYazaJvjOJm+iKHpXQM1P3LzGjt7Ff++Tp7nH4N8J/BUA7R9IHfDyx4DJIflifwnbmIA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.60.3':
resolution: {integrity: sha512-4YTNHKqGng5+yiZt3mg77nmyuCfmNfX4fPmyUapBcIk+BdwSwmCWGXOUxhXbBEkFHtoN5boLj/5NON+u5QC9tg==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-loong64-gnu@4.60.3':
resolution: {integrity: sha512-SU3kNlhkpI4UqlUc2VXPGK9o886ZsSeGfMAX2ba2b8DKmMXq4AL7KUrkSWVbb7koVqx41Yczx6dx5PNargIrEA==}
cpu: [loong64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-loong64-musl@4.60.3':
resolution: {integrity: sha512-6lDLl5h4TXpB1mTf2rQWnAk/LcXrx9vBfu/DT5TIPhvMhRWaZ5MxkIc8u4lJAmBo6klTe1ywXIUHFjylW505sg==}
cpu: [loong64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-ppc64-gnu@4.60.3':
resolution: {integrity: sha512-BMo8bOw8evlup/8G+cj5xWtPyp93xPdyoSN16Zy90Q2QZ0ZYRhCt6ZJSwbrRzG9HApFabjwj2p25TUPDWrhzqQ==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-ppc64-musl@4.60.3':
resolution: {integrity: sha512-E0L8X1dZN1/Rph+5VPF6Xj2G7JJvMACVXtamTJIDrVI44Y3K+G8gQaMEAavbqCGTa16InptiVrX6eM6pmJ+7qA==}
cpu: [ppc64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-riscv64-gnu@4.60.3':
resolution: {integrity: sha512-oZJ/WHaVfHUiRAtmTAeo3DcevNsVvH8mbvodjZy7D5QKvCefO371SiKRpxoDcCxB3PTRTLayWBkvmDQKTcX/sw==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-musl@4.60.3':
resolution: {integrity: sha512-Dhbyh7j9FybM3YaTgaHmVALwA8AkUwTPccyCQ79TG9AJUsMQqgN1DDEZNr4+QUfwiWvLDumW5vdwzoeUF+TNxQ==}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-s390x-gnu@4.60.3':
resolution: {integrity: sha512-cJd1X5XhHHlltkaypz1UcWLA8AcoIi1aWhsvaWDskD1oz2eKCypnqvTQ8ykMNI0RSmm7NkTdSqSSD7zM0xa6Ig==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.60.3':
resolution: {integrity: sha512-DAZDBHQfG2oQuhY7mc6I3/qB4LU2fQCjRvxbDwd/Jdvb9fypP4IJ4qmtu6lNjes6B531AI8cg1aKC2di97bUxA==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.60.3':
resolution: {integrity: sha512-cRxsE8c13mZOh3vP+wLDxpQBRrOHDIGOWyDL93Sy0Ga8y515fBcC2pjUfFwUe5T7tqvTvWbCpg1URM/AXdWIXA==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rollup/rollup-openbsd-x64@4.60.3':
resolution: {integrity: sha512-QaWcIgRxqEdQdhJqW4DJctsH6HCmo5vHxY0krHSX4jMtOqfzC+dqDGuHM87bu4H8JBeibWx7jFz+h6/4C8wA5Q==}
cpu: [x64]
os: [openbsd]
'@rollup/rollup-openharmony-arm64@4.60.3':
resolution: {integrity: sha512-AaXwSvUi3QIPtroAUw1t5yHGIyqKEXwH54WUocFolZhpGDruJcs8c+xPNDRn4XiQsS7MEwnYsHW2l0MBLDMkWg==}
cpu: [arm64]
os: [openharmony]
'@rollup/rollup-win32-arm64-msvc@4.60.3':
resolution: {integrity: sha512-65LAKM/bAWDqKNEelHlcHvm2V+Vfb8C6INFxQXRHCvaVN1rJfwr4NvdP4FyzUaLqWfaCGaadf6UbTm8xJeYfEg==}
cpu: [arm64]
os: [win32]
'@rollup/rollup-win32-ia32-msvc@4.60.3':
resolution: {integrity: sha512-EEM2gyhBF5MFnI6vMKdX1LAosE627RGBzIoGMdLloPZkXrUN0Ckqgr2Qi8+J3zip/8NVVro3/FjB+tjhZUgUHA==}
cpu: [ia32]
os: [win32]
'@rollup/rollup-win32-x64-gnu@4.60.3':
resolution: {integrity: sha512-E5Eb5H/DpxaoXH++Qkv28RcUJboMopmdDUALBczvHMf7hNIxaDZqwY5lK12UK1BHacSmvupoEWGu+n993Z0y1A==}
cpu: [x64]
os: [win32]
'@rollup/rollup-win32-x64-msvc@4.60.3':
resolution: {integrity: sha512-hPt/bgL5cE+Qp+/TPHBqptcAgPzgj46mPcg/16zNUmbQk0j+mOEQV/+Lqu8QRtDV3Ek95Q6FeFITpuhl6OTsAA==}
cpu: [x64]
os: [win32]
'@sinclair/typebox@0.27.10': '@sinclair/typebox@0.27.10':
resolution: {integrity: sha512-MTBk/3jGLNB2tVxv6uLlFh1iu64iYOQ2PbdOSK3NW8JZsmlaOh2q6sdtKowBhfw8QFLmYNzTW4/oK4uATIi6ZA==} resolution: {integrity: sha512-MTBk/3jGLNB2tVxv6uLlFh1iu64iYOQ2PbdOSK3NW8JZsmlaOh2q6sdtKowBhfw8QFLmYNzTW4/oK4uATIi6ZA==}
@ -663,9 +522,6 @@ packages:
'@types/estree-jsx@1.0.5': '@types/estree-jsx@1.0.5':
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==} resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
'@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
'@types/estree@1.0.9': '@types/estree@1.0.9':
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
@ -1058,8 +914,8 @@ packages:
resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
esbuild@0.21.5: esbuild@0.18.20:
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==}
engines: {node: '>=12'} engines: {node: '>=12'}
hasBin: true hasBin: true
@ -1840,9 +1696,9 @@ packages:
resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'} engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
rollup@4.60.3: rollup@3.30.0:
resolution: {integrity: sha512-pAQK9HalE84QSm4Po3EmWIZPd3FnjkShVkiMlz1iligWYkWQ7wHYd1PF/T7QZ5TVSD6uSTon5gBVMSM4JfBV+A==} resolution: {integrity: sha512-kQvGasUgN+AlWGliFn2POSajRQEsULVYFGTvOZmK06d7vCD+YhZztt70kGk3qaeAXeWYL5eO7zx+rAubBc55eA==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'} engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true hasBin: true
run-parallel@1.2.0: run-parallel@1.2.0:
@ -2085,16 +1941,15 @@ packages:
engines: {node: '>=v14.18.0'} engines: {node: '>=v14.18.0'}
hasBin: true hasBin: true
vite@5.4.21: vite@4.5.14:
resolution: {integrity: sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==} resolution: {integrity: sha512-+v57oAaoYNnO3hIu5Z/tJRZjq5aHM2zDve9YZ8HngVHbhk66RStobhb1sqPMIPEleV6cNKYK4eGrAbE9Ulbl2g==}
engines: {node: ^18.0.0 || >=20.0.0} engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
'@types/node': ^18.0.0 || >=20.0.0 '@types/node': '>= 14'
less: '*' less: '*'
lightningcss: ^1.21.0 lightningcss: ^1.21.0
sass: '*' sass: '*'
sass-embedded: '*'
stylus: '*' stylus: '*'
sugarss: '*' sugarss: '*'
terser: ^5.4.0 terser: ^5.4.0
@ -2107,8 +1962,6 @@ packages:
optional: true optional: true
sass: sass:
optional: true optional: true
sass-embedded:
optional: true
stylus: stylus:
optional: true optional: true
sugarss: sugarss:
@ -2345,73 +2198,70 @@ snapshots:
dependencies: dependencies:
'@jridgewell/trace-mapping': 0.3.9 '@jridgewell/trace-mapping': 0.3.9
'@esbuild/aix-ppc64@0.21.5': '@esbuild/android-arm64@0.18.20':
optional: true optional: true
'@esbuild/android-arm64@0.21.5': '@esbuild/android-arm@0.18.20':
optional: true optional: true
'@esbuild/android-arm@0.21.5': '@esbuild/android-x64@0.18.20':
optional: true optional: true
'@esbuild/android-x64@0.21.5': '@esbuild/darwin-arm64@0.18.20':
optional: true optional: true
'@esbuild/darwin-arm64@0.21.5': '@esbuild/darwin-x64@0.18.20':
optional: true optional: true
'@esbuild/darwin-x64@0.21.5': '@esbuild/freebsd-arm64@0.18.20':
optional: true optional: true
'@esbuild/freebsd-arm64@0.21.5': '@esbuild/freebsd-x64@0.18.20':
optional: true optional: true
'@esbuild/freebsd-x64@0.21.5': '@esbuild/linux-arm64@0.18.20':
optional: true optional: true
'@esbuild/linux-arm64@0.21.5': '@esbuild/linux-arm@0.18.20':
optional: true optional: true
'@esbuild/linux-arm@0.21.5': '@esbuild/linux-ia32@0.18.20':
optional: true optional: true
'@esbuild/linux-ia32@0.21.5': '@esbuild/linux-loong64@0.18.20':
optional: true optional: true
'@esbuild/linux-loong64@0.21.5': '@esbuild/linux-mips64el@0.18.20':
optional: true optional: true
'@esbuild/linux-mips64el@0.21.5': '@esbuild/linux-ppc64@0.18.20':
optional: true optional: true
'@esbuild/linux-ppc64@0.21.5': '@esbuild/linux-riscv64@0.18.20':
optional: true optional: true
'@esbuild/linux-riscv64@0.21.5': '@esbuild/linux-s390x@0.18.20':
optional: true optional: true
'@esbuild/linux-s390x@0.21.5': '@esbuild/linux-x64@0.18.20':
optional: true optional: true
'@esbuild/linux-x64@0.21.5': '@esbuild/netbsd-x64@0.18.20':
optional: true optional: true
'@esbuild/netbsd-x64@0.21.5': '@esbuild/openbsd-x64@0.18.20':
optional: true optional: true
'@esbuild/openbsd-x64@0.21.5': '@esbuild/sunos-x64@0.18.20':
optional: true optional: true
'@esbuild/sunos-x64@0.21.5': '@esbuild/win32-arm64@0.18.20':
optional: true optional: true
'@esbuild/win32-arm64@0.21.5': '@esbuild/win32-ia32@0.18.20':
optional: true optional: true
'@esbuild/win32-ia32@0.21.5': '@esbuild/win32-x64@0.18.20':
optional: true
'@esbuild/win32-x64@0.21.5':
optional: true optional: true
'@jest/diff-sequences@30.4.0': {} '@jest/diff-sequences@30.4.0': {}
@ -2531,81 +2381,6 @@ snapshots:
'@rolldown/pluginutils@1.0.0-beta.27': {} '@rolldown/pluginutils@1.0.0-beta.27': {}
'@rollup/rollup-android-arm-eabi@4.60.3':
optional: true
'@rollup/rollup-android-arm64@4.60.3':
optional: true
'@rollup/rollup-darwin-arm64@4.60.3':
optional: true
'@rollup/rollup-darwin-x64@4.60.3':
optional: true
'@rollup/rollup-freebsd-arm64@4.60.3':
optional: true
'@rollup/rollup-freebsd-x64@4.60.3':
optional: true
'@rollup/rollup-linux-arm-gnueabihf@4.60.3':
optional: true
'@rollup/rollup-linux-arm-musleabihf@4.60.3':
optional: true
'@rollup/rollup-linux-arm64-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-arm64-musl@4.60.3':
optional: true
'@rollup/rollup-linux-loong64-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-loong64-musl@4.60.3':
optional: true
'@rollup/rollup-linux-ppc64-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-ppc64-musl@4.60.3':
optional: true
'@rollup/rollup-linux-riscv64-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-riscv64-musl@4.60.3':
optional: true
'@rollup/rollup-linux-s390x-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-x64-gnu@4.60.3':
optional: true
'@rollup/rollup-linux-x64-musl@4.60.3':
optional: true
'@rollup/rollup-openbsd-x64@4.60.3':
optional: true
'@rollup/rollup-openharmony-arm64@4.60.3':
optional: true
'@rollup/rollup-win32-arm64-msvc@4.60.3':
optional: true
'@rollup/rollup-win32-ia32-msvc@4.60.3':
optional: true
'@rollup/rollup-win32-x64-gnu@4.60.3':
optional: true
'@rollup/rollup-win32-x64-msvc@4.60.3':
optional: true
'@sinclair/typebox@0.27.10': {} '@sinclair/typebox@0.27.10': {}
'@sinclair/typebox@0.34.49': {} '@sinclair/typebox@0.34.49': {}
@ -2697,8 +2472,6 @@ snapshots:
dependencies: dependencies:
'@types/estree': 1.0.9 '@types/estree': 1.0.9
'@types/estree@1.0.8': {}
'@types/estree@1.0.9': {} '@types/estree@1.0.9': {}
'@types/hast@3.0.4': '@types/hast@3.0.4':
@ -2759,7 +2532,7 @@ snapshots:
'@ungap/structured-clone@1.3.1': {} '@ungap/structured-clone@1.3.1': {}
'@vitejs/plugin-react@4.7.0(vite@5.4.21(@types/node@25.7.0))': '@vitejs/plugin-react@4.7.0(vite@4.5.14(@types/node@25.7.0))':
dependencies: dependencies:
'@babel/core': 7.29.0 '@babel/core': 7.29.0
'@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.29.0) '@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.29.0)
@ -2767,7 +2540,7 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.27 '@rolldown/pluginutils': 1.0.0-beta.27
'@types/babel__core': 7.20.5 '@types/babel__core': 7.20.5
react-refresh: 0.17.0 react-refresh: 0.17.0
vite: 5.4.21(@types/node@25.7.0) vite: 4.5.14(@types/node@25.7.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -3114,31 +2887,30 @@ snapshots:
has-tostringtag: 1.0.2 has-tostringtag: 1.0.2
hasown: 2.0.3 hasown: 2.0.3
esbuild@0.21.5: esbuild@0.18.20:
optionalDependencies: optionalDependencies:
'@esbuild/aix-ppc64': 0.21.5 '@esbuild/android-arm': 0.18.20
'@esbuild/android-arm': 0.21.5 '@esbuild/android-arm64': 0.18.20
'@esbuild/android-arm64': 0.21.5 '@esbuild/android-x64': 0.18.20
'@esbuild/android-x64': 0.21.5 '@esbuild/darwin-arm64': 0.18.20
'@esbuild/darwin-arm64': 0.21.5 '@esbuild/darwin-x64': 0.18.20
'@esbuild/darwin-x64': 0.21.5 '@esbuild/freebsd-arm64': 0.18.20
'@esbuild/freebsd-arm64': 0.21.5 '@esbuild/freebsd-x64': 0.18.20
'@esbuild/freebsd-x64': 0.21.5 '@esbuild/linux-arm': 0.18.20
'@esbuild/linux-arm': 0.21.5 '@esbuild/linux-arm64': 0.18.20
'@esbuild/linux-arm64': 0.21.5 '@esbuild/linux-ia32': 0.18.20
'@esbuild/linux-ia32': 0.21.5 '@esbuild/linux-loong64': 0.18.20
'@esbuild/linux-loong64': 0.21.5 '@esbuild/linux-mips64el': 0.18.20
'@esbuild/linux-mips64el': 0.21.5 '@esbuild/linux-ppc64': 0.18.20
'@esbuild/linux-ppc64': 0.21.5 '@esbuild/linux-riscv64': 0.18.20
'@esbuild/linux-riscv64': 0.21.5 '@esbuild/linux-s390x': 0.18.20
'@esbuild/linux-s390x': 0.21.5 '@esbuild/linux-x64': 0.18.20
'@esbuild/linux-x64': 0.21.5 '@esbuild/netbsd-x64': 0.18.20
'@esbuild/netbsd-x64': 0.21.5 '@esbuild/openbsd-x64': 0.18.20
'@esbuild/openbsd-x64': 0.21.5 '@esbuild/sunos-x64': 0.18.20
'@esbuild/sunos-x64': 0.21.5 '@esbuild/win32-arm64': 0.18.20
'@esbuild/win32-arm64': 0.21.5 '@esbuild/win32-ia32': 0.18.20
'@esbuild/win32-ia32': 0.21.5 '@esbuild/win32-x64': 0.18.20
'@esbuild/win32-x64': 0.21.5
escalade@3.2.0: {} escalade@3.2.0: {}
@ -4078,35 +3850,8 @@ snapshots:
reusify@1.1.0: {} reusify@1.1.0: {}
rollup@4.60.3: rollup@3.30.0:
dependencies:
'@types/estree': 1.0.8
optionalDependencies: optionalDependencies:
'@rollup/rollup-android-arm-eabi': 4.60.3
'@rollup/rollup-android-arm64': 4.60.3
'@rollup/rollup-darwin-arm64': 4.60.3
'@rollup/rollup-darwin-x64': 4.60.3
'@rollup/rollup-freebsd-arm64': 4.60.3
'@rollup/rollup-freebsd-x64': 4.60.3
'@rollup/rollup-linux-arm-gnueabihf': 4.60.3
'@rollup/rollup-linux-arm-musleabihf': 4.60.3
'@rollup/rollup-linux-arm64-gnu': 4.60.3
'@rollup/rollup-linux-arm64-musl': 4.60.3
'@rollup/rollup-linux-loong64-gnu': 4.60.3
'@rollup/rollup-linux-loong64-musl': 4.60.3
'@rollup/rollup-linux-ppc64-gnu': 4.60.3
'@rollup/rollup-linux-ppc64-musl': 4.60.3
'@rollup/rollup-linux-riscv64-gnu': 4.60.3
'@rollup/rollup-linux-riscv64-musl': 4.60.3
'@rollup/rollup-linux-s390x-gnu': 4.60.3
'@rollup/rollup-linux-x64-gnu': 4.60.3
'@rollup/rollup-linux-x64-musl': 4.60.3
'@rollup/rollup-openbsd-x64': 4.60.3
'@rollup/rollup-openharmony-arm64': 4.60.3
'@rollup/rollup-win32-arm64-msvc': 4.60.3
'@rollup/rollup-win32-ia32-msvc': 4.60.3
'@rollup/rollup-win32-x64-gnu': 4.60.3
'@rollup/rollup-win32-x64-msvc': 4.60.3
fsevents: 2.3.3 fsevents: 2.3.3
run-parallel@1.2.0: run-parallel@1.2.0:
@ -4403,23 +4148,22 @@ snapshots:
mlly: 1.8.2 mlly: 1.8.2
pathe: 1.1.2 pathe: 1.1.2
picocolors: 1.1.1 picocolors: 1.1.1
vite: 5.4.21(@types/node@25.7.0) vite: 4.5.14(@types/node@25.7.0)
transitivePeerDependencies: transitivePeerDependencies:
- '@types/node' - '@types/node'
- less - less
- lightningcss - lightningcss
- sass - sass
- sass-embedded
- stylus - stylus
- sugarss - sugarss
- supports-color - supports-color
- terser - terser
vite@5.4.21(@types/node@25.7.0): vite@4.5.14(@types/node@25.7.0):
dependencies: dependencies:
esbuild: 0.21.5 esbuild: 0.18.20
postcss: 8.5.14 postcss: 8.5.14
rollup: 4.60.3 rollup: 3.30.0
optionalDependencies: optionalDependencies:
'@types/node': 25.7.0 '@types/node': 25.7.0
fsevents: 2.3.3 fsevents: 2.3.3
@ -4447,7 +4191,7 @@ snapshots:
strip-literal: 1.3.0 strip-literal: 1.3.0
tinybench: 2.9.0 tinybench: 2.9.0
tinypool: 0.7.0 tinypool: 0.7.0
vite: 5.4.21(@types/node@25.7.0) vite: 4.5.14(@types/node@25.7.0)
vite-node: 0.34.6(@types/node@25.7.0) vite-node: 0.34.6(@types/node@25.7.0)
why-is-node-running: 2.3.0 why-is-node-running: 2.3.0
optionalDependencies: optionalDependencies:
@ -4456,7 +4200,6 @@ snapshots:
- less - less
- lightningcss - lightningcss
- sass - sass
- sass-embedded
- stylus - stylus
- sugarss - sugarss
- supports-color - supports-color

View File

@ -49,11 +49,11 @@ export const QueryInput: React.FC<QueryInputProps> = ({ onSubmit, onHalfQuestion
} }
} }
const isDisabled = isLoading || displayValue.trim() === '' const isDisabled = isLoading || displayValue.trim() === '' || (!hasUserInput && !!partialText)
const textareaClassName = [ const textareaClassName = [
'w-full rounded border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed', 'w-full rounded border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed',
'', showPartialStyle ? 'text-gray-400 italic' : '',
].filter(Boolean).join(' ') ].filter(Boolean).join(' ')
return ( return (

View File

@ -3,7 +3,7 @@ import { MessageSquare, AlertCircle, Copy, ChevronDown, ChevronRight } from 'luc
import ReactMarkdown from 'react-markdown' import ReactMarkdown from 'react-markdown'
import type { SourceMetadata, SubQuestionSources } from '../types' import type { SourceMetadata, SubQuestionSources } from '../types'
import { getPdfViewerUrl } from '../lib/api' import { getPdfViewerUrl } from '../lib/api'
import { processCitations, processCitationsForSubq, extractCitedSources } from '../utils/citationParser' import { processCitations, processCitationsForSubq, extractCitedSources, highlightTerms } from '../utils/citationParser'
import { bulletizeMarkdown } from '../utils/citationParser' import { bulletizeMarkdown } from '../utils/citationParser'
function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string { function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string {
@ -32,6 +32,10 @@ const CitationLink = ({ href, children }: { href?: string; children?: React.Reac
</a> </a>
) )
const HighlightMark = ({ children }: { children?: React.ReactNode }) => (
<mark className="bg-yellow-200 rounded px-0.5">{children}</mark>
)
function parseAnswerSections(answer: string): string[] { function parseAnswerSections(answer: string): string[] {
const sections = answer.split(/## Sub-question \d+:[^\n]*\n/) const sections = answer.split(/## Sub-question \d+:[^\n]*\n/)
if (sections.length <= 1) return [bulletizeMarkdown(answer)] if (sections.length <= 1) return [bulletizeMarkdown(answer)]
@ -107,6 +111,7 @@ function SubQuestionSection({
sq.sources.map(s => ({ ...s, sub_question_text: sq.sub_question_text })) sq.sources.map(s => ({ ...s, sub_question_text: sq.sub_question_text }))
) )
const processedAnswer = processCitations(answerSection, allSources, highlightReadyKeys) const processedAnswer = processCitations(answerSection, allSources, highlightReadyKeys)
const highlightedAnswer = highlightTerms(processedAnswer)
return ( return (
<div <div
@ -120,8 +125,8 @@ function SubQuestionSection({
</div> </div>
<div className="prose prose-sm max-w-none text-gray-800"> <div className="prose prose-sm max-w-none text-gray-800">
<ReactMarkdown components={{ a: CitationLink }}> <ReactMarkdown components={{ a: CitationLink, mark: HighlightMark }}>
{processedAnswer} {highlightedAnswer}
</ReactMarkdown> </ReactMarkdown>
</div> </div>
@ -373,6 +378,7 @@ function FlatResponse({
const safeSources = sources ?? [] const safeSources = sources ?? []
const processedAnswer = answer ? processCitations(answer, safeSources) : answer ?? '' const processedAnswer = answer ? processCitations(answer, safeSources) : answer ?? ''
const highlightedAnswer = processedAnswer ? highlightTerms(processedAnswer) : processedAnswer
const handleCopyAnswer = async (): Promise<void> => { const handleCopyAnswer = async (): Promise<void> => {
if (answer) { if (answer) {
@ -474,9 +480,9 @@ function FlatResponse({
</div> </div>
<div className="prose prose-sm max-w-none text-gray-800"> <div className="prose prose-sm max-w-none text-gray-800">
<ReactMarkdown <ReactMarkdown
components={{ a: CitationLink }} components={{ a: CitationLink, mark: HighlightMark }}
> >
{processedAnswer} {highlightedAnswer}
</ReactMarkdown> </ReactMarkdown>
</div> </div>
</div> </div>

View File

@ -10,3 +10,8 @@
list-style: decimal !important; list-style: decimal !important;
padding-left: 1.5rem !important; padding-left: 1.5rem !important;
} }
.prose mark {
background-color: #FEF08A;
border-radius: 0.125rem;
padding: 0 0.125rem;
}

View File

@ -197,7 +197,7 @@ describe('ResponsePanel', () => {
/> />
) )
const citationLink = screen.getByRole('link', { name: /NEC4 ACC\.pdf, page 3/ }) const citationLink = screen.getByRole('link', { name: '1' })
expect(citationLink).toBeInTheDocument() expect(citationLink).toBeInTheDocument()
expect(citationLink).toHaveAttribute('target', '_blank') expect(citationLink).toHaveAttribute('target', '_blank')
expect(citationLink).toHaveAttribute('href', expect.stringContaining('/pdf-viewer')) expect(citationLink).toHaveAttribute('href', expect.stringContaining('/pdf-viewer'))

View File

@ -43,14 +43,14 @@ describe('processCitations', () => {
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('](') expect(result).toContain('](')
expect(result).toContain('/pdf-viewer') expect(result).toContain('/pdf-viewer')
expect(result).toMatch(/\[NEC4 ACC\.pdf, page 3\]\([^)]+\)/) expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('handles filename-only citation for DOCX (no page)', () => { it('handles filename-only citation for DOCX (no page)', () => {
const text = 'Notes [meeting_notes.docx] from meeting.' const text = 'Notes [meeting_notes.docx] from meeting.'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('/pdf-viewer') expect(result).toContain('/pdf-viewer')
expect(result).toContain('meeting_notes.docx') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('leaves unmatched citations as plain text', () => { it('leaves unmatched citations as plain text', () => {
@ -64,26 +64,28 @@ describe('processCitations', () => {
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
const linkCount = (result.match(/\[.+?\]\(/g) || []).length const linkCount = (result.match(/\[.+?\]\(/g) || []).length
expect(linkCount).toBe(2) expect(linkCount).toBe(2)
expect(result).toMatch(/\[1\]\([^)]+\)/)
expect(result).toMatch(/\[2\]\([^)]+\)/)
}) })
it('does not break existing markdown links', () => { it('does not break existing markdown links', () => {
const text = 'See [label](http://example.com) and [NEC4 ACC.pdf, page 3].' const text = 'See [label](http://example.com) and [NEC4 ACC.pdf, page 3].'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('[label](http://example.com)') expect(result).toContain('[label](http://example.com)')
expect(result).toContain('/pdf-viewer') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('does not break markdown images', () => { it('does not break markdown images', () => {
const text = '![diagram](http://example.com/img.png) and [NEC4 ACC.pdf, page 3].' const text = '![diagram](http://example.com/img.png) and [NEC4 ACC.pdf, page 3].'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('![diagram]') expect(result).toContain('![diagram]')
expect(result).toContain('/pdf-viewer') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('matches case-insensitively', () => { it('matches case-insensitively', () => {
const text = 'Cite [nec4 acc.pdf, page 3] lowercase.' const text = 'Cite [nec4 acc.pdf, page 3] lowercase.'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('/pdf-viewer') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('leaves plain bracket text without matching source', () => { it('leaves plain bracket text without matching source', () => {
@ -107,6 +109,7 @@ describe('processCitations', () => {
const text = 'Source [no_path.pdf, page 1] with document link.' const text = 'Source [no_path.pdf, page 1] with document link.'
const result = processCitations(text, sourcesWithoutPath) const result = processCitations(text, sourcesWithoutPath)
expect(result).toContain('/rag-database?document=doc-fallback') expect(result).toContain('/rag-database?document=doc-fallback')
expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('remains plain text when both chunk_file_path and document_id are null', () => { it('remains plain text when both chunk_file_path and document_id are null', () => {
@ -130,19 +133,19 @@ describe('processCitations', () => {
const text = 'See [NEC4 ACC, page 3] without .pdf extension.' const text = 'See [NEC4 ACC, page 3] without .pdf extension.'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('/pdf-viewer') expect(result).toContain('/pdf-viewer')
expect(result).toContain('NEC4 ACC, page 3') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('fuzzy matches citation with different case and without extension', () => { it('fuzzy matches citation with different case and without extension', () => {
const text = 'Cite [nec4 acc] lowercase no extension.' const text = 'Cite [nec4 acc] lowercase no extension.'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('/pdf-viewer') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
it('fuzzy matches filename-only citation without extension', () => { it('fuzzy matches filename-only citation without extension', () => {
const text = 'Notes [meeting_notes] from meeting (no .docx).' const text = 'Notes [meeting_notes] from meeting (no .docx).'
const result = processCitations(text, mockSources) const result = processCitations(text, mockSources)
expect(result).toContain('/pdf-viewer') expect(result).toMatch(/\[1\]\([^)]+\)/)
}) })
}) })

View File

@ -0,0 +1,73 @@
import { describe, it, expect } from 'vitest'
import { highlightTerms } from '../../utils/citationParser'
describe('highlightTerms', () => {
it('converts single ==term== to mark element', () => {
const input = 'This is ==important== text.'
const result = highlightTerms(input)
expect(result).toBe('This is <mark class="bg-yellow-200 rounded px-0.5">important</mark> text.')
})
it('converts multiple ==term== markers in one string', () => {
const input = '==First== and ==second== highlight.'
const result = highlightTerms(input)
expect(result).toBe(
'<mark class="bg-yellow-200 rounded px-0.5">First</mark> and <mark class="bg-yellow-200 rounded px-0.5">second</mark> highlight.'
)
})
it('returns text unchanged when no markers present', () => {
const input = 'This text has no highlights.'
const result = highlightTerms(input)
expect(result).toBe(input)
})
it('returns empty string for empty input', () => {
const result = highlightTerms('')
expect(result).toBe('')
})
it('handles numeric values like ==HK$1,000,000==', () => {
const input = 'Amount: ==HK$1,000,000=='
const result = highlightTerms(input)
expect(result).toBe('Amount: <mark class="bg-yellow-200 rounded px-0.5">HK$1,000,000</mark>')
})
it('handles percentage values like ==35%==', () => {
const input = 'Rate: ==35%=='
const result = highlightTerms(input)
expect(result).toBe('Rate: <mark class="bg-yellow-200 rounded px-0.5">35%</mark>')
})
it('handles date values like ==1 January 2024==', () => {
const input = 'Date: ==1 January 2024=='
const result = highlightTerms(input)
expect(result).toBe('Date: <mark class="bg-yellow-200 rounded px-0.5">1 January 2024</mark>')
})
it('handles adjacent markers ==foo== ==bar==', () => {
const input = '==foo== ==bar=='
const result = highlightTerms(input)
expect(result).toBe(
'<mark class="bg-yellow-200 rounded px-0.5">foo</mark> <mark class="bg-yellow-200 rounded px-0.5">bar</mark>'
)
})
it('does not highlight markers inside backtick code spans', () => {
const input = 'Code: `==code==` and ==highlight=='
const result = highlightTerms(input)
expect(result).toBe('Code: `==code==` and <mark class="bg-yellow-200 rounded px-0.5">highlight</mark>')
})
it('does not highlight markers adjacent to backticks', () => {
const input = '`==not me==` ==but me== `==also not==`'
const result = highlightTerms(input)
expect(result).toBe('`==not me==` <mark class="bg-yellow-200 rounded px-0.5">but me</mark> `==also not==`')
})
it('passes through plain markdown text without markers unchanged', () => {
const input = '## Heading\n\n- Bullet one\n- **Bold text**\n\n[A link](http://example.com)'
const result = highlightTerms(input)
expect(result).toBe(input)
})
})

View File

@ -108,6 +108,7 @@ function replaceCitationPatterns(
highlightKeys?: Set<string> highlightKeys?: Set<string>
): string { ): string {
const citationPattern = /(?<!!)\[([^\]]+)\](?!\()/g const citationPattern = /(?<!!)\[([^\]]+)\](?!\()/g
let refCounter = 0
return text.replace(citationPattern, (fullMatch, content: string) => { return text.replace(citationPattern, (fullMatch, content: string) => {
const trimmed = content.trim() const trimmed = content.trim()
@ -122,7 +123,8 @@ function replaceCitationPatterns(
} }
const url = buildCitationUrl(source, isReady) const url = buildCitationUrl(source, isReady)
if (url) { if (url) {
return `[${trimmed}](${url})` refCounter++
return `[${refCounter}](${url})`
} }
} }
@ -160,3 +162,13 @@ export function extractCitedSources(answerText: string, sources: SourceMetadata[
return result return result
} }
export function highlightTerms(markdown: string): string {
const parts = markdown.split(/(`[^`]*`)/)
return parts
.map((part, index) => {
if (index % 2 === 1) return part
return part.replace(/(?<!`)==(.+?)==(?!`)/g, '<mark class="bg-yellow-200 rounded px-0.5">$1</mark>')
})
.join('')
}