fix(apollo-react): render citation page number in ap-chat (JAR-9997)#871
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency License Review
License distribution
Excluded packages
|
📊 Coverage + size by packagePer-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.
"Coverage" is each package's own |
There was a problem hiding this comment.
Pull request overview
Fixes a Lingui placeholder-key mismatch in ApChat PDF citations so page numbers interpolate correctly in localized “Page N” strings.
Changes:
- Update citation rendering to interpolate
page_number(snake_case) so it matches the locale catalog placeholder. - Apply the same fix in both the inline “sources” list and the markdown citation component.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/apollo-react/src/material/components/ap-chat/components/message/sources/chat-sources.tsx | Aligns the interpolated page-number value key with the {page_number} placeholder used in locale catalogs. |
| packages/apollo-react/src/material/components/ap-chat/components/message/markdown/citation.tsx | Fixes the citation component’s Lingui interpolation to use page_number so localized templates substitute correctly. |
Citation and ChatSources passed the page value under a camelCase
`pageNumber` key, but the compiled locale catalogs use the snake_case
`{page_number}` placeholder for `autopilot-chat.message.page-number`.
The keys never matched, so PDF citations rendered an empty "(Page )".
Interpolate `page_number` directly so the Lingui macro emits a matching
values key. Verified against the shipped compiled `en` catalog:
values:{ pageNumber: 2 } -> "Page " (before)
values:{ page_number: 2 } -> "Page 2" (after)
JAR-9997
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address review feedback: derive `page_number` once as `number | undefined` (undefined when the source isn't a PDF) and reuse it for both the render condition and the interpolation. Removes the misleading `0` fallback that was never rendered and the duplicated `isPdf && source.page_number` guard. JAR-9997 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6443675 to
fbba5d1
Compare
Summary
PDF citations in
ApChatrender an empty(Page )instead of(Page N). This is a placeholder-key mismatch between the source and the locale catalogs.uipath-ui-widgets(citations). The widget mapspageNumbercorrectly and the value reaches apollo intact, so the defect is apollo-side.Root cause
autopilot-chat.message.page-numberis defined in every locale catalog with a snake_case placeholder:But the components interpolate a camelCase variable, so the Lingui macro emits
values: { pageNumber }.page_number≠pageNumber, so substitution finds nothing and the number renders empty.packages/apollo-react/src/material/components/ap-chat/components/message/markdown/citation.tsxpackages/apollo-react/src/material/components/ap-chat/components/message/sources/chat-sources.tsxFix
Interpolate
page_numberdirectly so the macro-emitted values key matches the catalog placeholder. No catalog changes, works across all 13 locales.Proof
Run against the shipped compiled
encatalog + real@lingui/coreruntime (no mocks):Note / open question for the Apollo team
page_numberis the only snake_case placeholder in the ap-chat catalog — every other one is camelCase (maxSize,fileName,title,count, ...). This PR aligns the source down to the outlier because it's the lowest-risk change (all 13 catalogs are already snake_case; no translation re-sync). If you'd rather converge on the camelCase convention, the alternative is renaming the placeholder to{pageNumber}across thelocales/*.jsonfiles instead. Happy to flip it either way — flagging for your call.🤖 Generated with Claude Code