Skip to content

fix(apollo-react): render citation page number in ap-chat (JAR-9997)#871

Merged
scottcmg merged 3 commits into
mainfrom
fix/jar-9997-citation-page-number
Jul 2, 2026
Merged

fix(apollo-react): render citation page number in ap-chat (JAR-9997)#871
scottcmg merged 3 commits into
mainfrom
fix/jar-9997-citation-page-number

Conversation

@scottcmg

@scottcmg scottcmg commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

PDF citations in ApChat render an empty (Page ) instead of (Page N). This is a placeholder-key mismatch between the source and the locale catalogs.

  • JAR: JAR-9997
  • Surfaced by: the Widget SDK migration in uipath-ui-widgets (citations). The widget maps pageNumber correctly and the value reaches apollo intact, so the defect is apollo-side.

Root cause

autopilot-chat.message.page-number is defined in every locale catalog with a snake_case placeholder:

"autopilot-chat.message.page-number": "Page {page_number}"

But the components interpolate a camelCase variable, so the Lingui macro emits values: { pageNumber }. page_numberpageNumber, so substitution finds nothing and the number renders empty.

  • packages/apollo-react/src/material/components/ap-chat/components/message/markdown/citation.tsx
  • packages/apollo-react/src/material/components/ap-chat/components/message/sources/chat-sources.tsx

Fix

Interpolate page_number directly so the macro-emitted values key matches the catalog placeholder. No catalog changes, works across all 13 locales.

Proof

Run against the shipped compiled en catalog + real @lingui/core runtime (no mocks):

Compiled en template for autopilot-chat.message.page-number:
    ["Page ",["page_number"]]

CURRENT code  -> values:{ pageNumber:2 }  renders: "Page "
FIXED code    -> values:{ page_number:2 } renders: "Page 2"

Note / open question for the Apollo team

page_number is 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 the locales/*.json files instead. Happy to flip it either way — flagging for your call.

Draft: not verified in Storybook locally (the design Storybook install is gated behind the private @uipath/core-telemetry GitHub Packages registry). Requesting an Apollo reviewer to confirm visually via Material → Components → Chat → "Stream With Citations" (the sources list shows [3] Discovery Phase Guide (Page ) before / (Page 2) after).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 1, 2026 19:01
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (PT)
apollo-design 🟢 Ready Preview, Logs Jul 02, 2026, 01:12:51 PM
apollo-docs 🟢 Ready Preview, Logs Jul 02, 2026, 01:12:51 PM
apollo-landing 🟢 Ready Preview, Logs Jul 02, 2026, 01:12:51 PM
apollo-vertex 🟢 Ready Preview, Logs Jul 02, 2026, 01:12:51 PM

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Dependency License Review

  • 1945 package(s) scanned
  • ✅ No license issues found
  • ⚠️ 2 package(s) excluded (see details below)
License distribution
License Packages
MIT 1715
ISC 89
Apache-2.0 55
BSD-3-Clause 27
BSD-2-Clause 23
BlueOak-1.0.0 8
MPL-2.0 4
MIT-0 3
CC0-1.0 3
MIT OR Apache-2.0 2
(MIT OR Apache-2.0) 2
Unlicense 2
LGPL-3.0-or-later 1
Python-2.0 1
CC-BY-4.0 1
(MPL-2.0 OR Apache-2.0) 1
Unknown 1
Artistic-2.0 1
(WTFPL OR MIT) 1
(BSD-2-Clause OR MIT OR Apache-2.0) 1
CC-BY-3.0 1
0BSD 1
(MIT OR CC0-1.0) 1
MIT AND ISC 1
Excluded packages
Package Version License Reason
@img/sharp-libvips-linux-x64 1.2.4 LGPL-3.0-or-later LGPL pre-built binary, not linked
khroma 2.1.0 Unknown MIT per GitHub repo, missing license field in package.json

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage + size by package

Per-package coverage and bundle size on this PR. New-line coverage = of the source lines this PR adds or changes, the % hit by tests.

Package Coverage New-line coverage Packed (gzip) Unpacked vs main
@uipath/apollo-core 9.0% 43.82 MB 57.31 MB ±0
@uipath/apollo-react 34.7% 0.0% (0/2) 7.27 MB 27.60 MB −71 B
@uipath/apollo-wind 40.1% 392.4 KB 2.55 MB −16 B
@uipath/ap-chat 85.8% 43.41 MB 55.85 MB +14 B

"Coverage" is each package's own coverage.include scope (e.g. apollo-core instruments only scripts/). "Packed"/"Unpacked" come from npm pack --dry-run and only cover built packages — "—" means not measured this run (package not affected / not built). "vs main" is the packed (gzipped) delta against the last successful main build (the package-sizes artifact from the Release workflow); "—" there means no main baseline was available this run. The baseline is main's latest build, not this PR's exact merge-base, so it includes any drift since the branch diverged. Packages with no vitest config are omitted.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings July 1, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings July 1, 2026 19:08
@github-actions github-actions Bot added size:S 10-29 changed lines. and removed size:XS 0-9 changed lines. labels Jul 1, 2026
@scottcmg scottcmg marked this pull request as ready for review July 1, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

scottcmg and others added 2 commits July 1, 2026 12:12
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>
@scottcmg scottcmg force-pushed the fix/jar-9997-citation-page-number branch from 6443675 to fbba5d1 Compare July 1, 2026 19:12
Copilot AI review requested due to automatic review settings July 2, 2026 20:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@scottcmg scottcmg merged commit 5503465 into main Jul 2, 2026
43 of 44 checks passed
@scottcmg scottcmg deleted the fix/jar-9997-citation-page-number branch July 2, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:apollo-react size:S 10-29 changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants