Skip to content

Restore Shinychat ownership of verified citation display - #127

Merged
simonpcouch merged 20 commits into
mainfrom
feat/native-numbered-citations
Aug 19, 2026
Merged

Restore Shinychat ownership of verified citation display#127
simonpcouch merged 20 commits into
mainfrom
feat/native-numbered-citations

Conversation

@cpsievert

@cpsievert cpsievert commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

This PR restores the boundary originally established in #107: Commons is responsible for server-side citation verification and audit records; Shinychat is responsible for client-side citation display and interaction.

Shinychat#326 adds compact asides (i.e., superscripts), letting Commons request and style compact citations through supported display and CSS APIs rather than reconstructing citation UI with custom markup and private selectors.

Behavior

  • Verified citations render as compact numbered references, with the source label and icon available in the popover and accessible name.
  • Citation streaming preserves surrounding Markdown whitespace.
  • Commons records citation decisions in the answer audit trail, and trajectory review replays those recorded decisions.

Verification

Citation scanner and trajectory-review tests cover projection and replay. Browser tests cover streamed compact citations, source-aware markers, and popovers.

Closes #123.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Preview deployed to Connect (dogfood.team.pct.posit.it): https://dogfood.team.pct.posit.it/connect/#/apps/d7a36cae-8f27-448b-a478-61b81fbe3942/draft/362777

Deployed from commit ade21dd.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Preview deployed to Connect (connect.staging.pct.posit.it): https://connect.staging.pct.posit.it/connect/#/apps/ad662e1b-5048-4acc-9ad7-f9478c92274e/draft/1985

Deployed from commit ade21dd.

@simonpcouch simonpcouch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! Happy to take this on after some iteration.

Two UI pieces that related PRs and commits have had some back and forth on--in this:

Image
  1. I would prefer that the text in the pills is not bolded. I think the shinychat default weight is 600 and I had changed it to 400.
  2. The "Verified answer" badge and text doesn't need to be duplicated inside of the popup

Also, with this PR, I'm seeing that citations often land on separate lines:

Image

Otherwise, the UI changes are fine with me!

Comment thread inst/prompts/citation-request.md Outdated
- Citations are rendered as footnotes at the end of the preceding line. Place
each citation on its own line immediately after the text it supports; that
text should stand on its own.
- Place each citation immediately after the paragraph it supports.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From my understanding of the changes, it doesn't seem necessary to change this line? If so, my more concrete feedback is that I'd prefer not to say "paragraph" here, which might make the agent think it should refrain from writing short replies in favor of writing paragraphs.

@cpsievert cpsievert Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yea, thanks for catching this. Fixed in 9d82a3b.

Comment thread R/citation-scan.R Outdated
# State spans the unflushed raw-input tail, the text/citation/discard mode, and
# whether the next raw character is at line start. Text mode retains only a
# trailing prefix of a reserved literal; citation mode buffers one bounded
# element body; discard mode drops invalid reserved markup through its close.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you do a pass on these comments with a GPT or otherwise non-Claude model, asking the agent to remove all new code comments and then restore only those that speak to the "why" rather than the "what" with clear, concise language? I find Claude code comments to be quite hard to read and often much longer than they need to be.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Relatedly, if you could write a couple sentences in the PR description yourself that help me orient to the changes and understand what you're going for, that would be appreciated! These Claude-generated PR descriptions are hard to parse for me

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed the scanner implementation narration and audited the other new comments. The remaining comments are concise rationale for cross-layer trust, trace-lineage, and temporary Shinychat contracts. Updated in 8bff158.

Comment thread inst/www/commons-chat/commons-chat.css
Comment thread inst/www/commons-chat/commons-chat.css Outdated
Comment thread R/citations.R Outdated
Comment on lines +99 to +102
'<small class="text-body-secondary">',
"Quote matched exactly against trusted context. ",
"Explanation generated by AI.",
"</small>"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove this

@cpsievert cpsievert Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, fixed in 2adbedd.

Comment thread R/trajectory-review.R Outdated

# trajectory_read() attaches one recorded provenance entry per reconstructed
# exchange. Review rendering consumes that audit record rather than re-deriving
# trust from message text.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would prefer that these comment-additions-only changes to otherwise unchanged files would be reverted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed the comment-only additions from trajectory-review.R in 8bff158.

@cpsievert

cpsievert commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator Author

I would prefer that the text in the pills is not bolded.

Done in cb33814

The "Verified answer" badge and text doesn't need to be duplicated inside of the popup

Ahh, good catch. For multi-page <shiny-aside>, showing the label/icon is usually what you want since they can change, but for single-page it makes sense to drop them. Fixed via posit-dev/shinychat@16df7d5

I'm seeing that citations often land on separate lines

Another good catch. <shiny-aside> already has some heuristics to bring the asides inline to the preceding paragraph / list item when it makes sense to. It wasn't capturing a case like this though: Text\n\n<shiny-aside>. Addressed via posit-dev/shinychat#327, but please lmk if you encounter more situations like this!

@cpsievert
cpsievert marked this pull request as ready for review August 19, 2026 01:24

@simonpcouch simonpcouch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great, thanks!

[edit: there had previously been a screenshot here where i said there was still a newline before citations. i was wrong--didn't have the most recent shinychat. that's fixed!]

Otherwise, looks good. I trust you to make changes as needed and merge when the changes are ready!

Comment thread inst/prompts/citation-request.md Outdated
Co-authored-by: Simon P. Couch <simonpatrickcouch@gmail.com>
@simonpcouch
simonpcouch merged commit c19379e into main Aug 19, 2026
4 checks passed
@simonpcouch
simonpcouch deleted the feat/native-numbered-citations branch August 19, 2026 17:14
@github-actions

Copy link
Copy Markdown

Cleaned up 6 preview bundle(s) on https://dogfood.team.pct.posit.it: 362412, 362413, 362439, 362440, 362444, 362777

@github-actions

Copy link
Copy Markdown

Cleaned up 6 preview bundle(s) on https://connect.staging.pct.posit.it: 1886, 1896, 1927, 1928, 1932, 1985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline citation attachment can break block Markdown and hide verified citations

2 participants