Skip to content

feat(quotes): render citation previews as markdown - #612

Merged
nixuuu merged 2 commits into
devfrom
feat/markdown-citation-previews
Nov 13, 2026
Merged

nixuuu merged 2 commits into
devfrom
feat/markdown-citation-previews

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Render citation bodies as safe Markdown in sent-message and composer previews, with compact headings, task lists, links, formatted code and bounded scrolling. Show the source caption and GitHub link separately; keep citation notes literal. Mobile uses its existing native Markdown renderer in a lazily mounted citation viewer.

Whole-message citations retain their source under agent_message_markdown. Existing rendered thread selections stay plain; PR selections use text_selection, preserving owner-scoped PR source resolution. Only PR comment/review bodies and explicitly marked whole messages render Markdown. Shared domain helpers clean chip labels and composer title fallbacks without lexing every chip.

Validation

  • With nice -n 10: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, bun run --filter @canopy/web build, and the full bun run check:tmp pass. The full run reports 2678 passing tests, zero failures, and nothing left in its temp directory.
  • Domain regression tests pass for markdown label cleanup, structured source/notes, literal selections, and source-kind classification. The gateway/harness citation tests also pass for preserving a PR selection's kind while resolving its author, path and context from the owner-scoped cache.
  • Manually checked production components in an isolated Chromium session on the second machine: light/dark at 1440×1000 and 390×844, sent-message and composer previews, short whole messages, a long PR comment with heading/tasks/links/code, and literal thread selections. Checked long repository/path captions, native title fallback, actual scrolling, selectable text, unsafe-link rejection, and zero mounted preview bodies before opening. No UI test suite was added.
  • Both local and second-machine web builds pass. The isolated remote browser, server, database container and checkout have been removed. Mobile is typechecked and uses the existing native renderer; it was not exercised on a device.

Copy audit — docs/copy.md §8

  • Raw @claude[bot] · **Claude finished … → @claude[bot] · Claude finished …: remove presentation syntax from markdown-source labels and title fallbacks. Literal source punctuation stays unchanged.
  • Body and provenance joined into one raw paragraph → formatted quote, muted source caption, separate Open on GitHub action, and literal note: each part has one purpose. Open on GitHub remains a three-word imperative in sentence case. Mobile Copy output → Copy quote names the content being copied.
  • Criteria 1–8 and 10: English copy follows sentence case and the citation/quote glossary; no new errors, empty states, jargon, repeated explanatory copy, missing-data warnings or “soul” lines. Actions have text/accessibility labels and do not depend on color or position.
  • Criterion 9: checked short, typical and long source names/captions at desktop and phone widths in both themes; captions wrap, labels truncate, notes retain their punctuation, and overlays stay within the viewport.

@nixuuu
nixuuu marked this pull request as ready for review November 13, 2026 08:55
@nixuuu
nixuuu merged commit 993742e into dev Nov 13, 2026
12 checks passed
@nixuuu
nixuuu deleted the feat/markdown-citation-previews branch November 13, 2026 08:56
nixuuu added a commit that referenced this pull request Nov 13, 2026
Short citations opened a fixed-width (320 px) card, padded by the
selection's leading/trailing line breaks (user screenshot: one short
line in a large card).

- Citation hover card and composer citation preview: `w-max` up to
`min(20rem, 100vw - 1rem)`.
- `citationPreview` trims the quoted text and the note.
- `HoverCard`: a caller's class replaces the default `w-72` instead of
adding a second, conflicting width utility.

Text sizes already follow the overlay density (docs/ui-scale.md); the
large font in the report came from a build before #612.

Related: #612

### Copy audit (docs/copy.md §8)
No UI text changed.

### Checks
install, typecheck, lint, format:check and the quotes domain tests clean
locally; full tests and web build in CI. Not yet checked in a browser.
nixuuu added a commit that referenced this pull request Nov 13, 2026
Current `dev` already renders ranged citations inline in sent and queued
mobile messages. Share the pure UTF-16 range helper between composer
spans and sent-message Markdown so both paths retain the same model, and
cover it with five regression tests. Legacy quotes without ranges keep
their block presentation until the queue editor applies
`inlineLegacyQuotes`.

The viewer already shows the full, literal note in a scrollable view.
Keep the same chip convention as web, without an additional note
indicator. No native code, dependencies, configuration or web UI
changes.

## Diagnosis and installed bundle

- The parent of #591 unconditionally rendered every quote through
`MessageQuotes` and passed only mention ranges to Markdown. Its older
protobuf schema also lacked citation ranges. That implementation matches
the reported blocks plus raw placeholders. #591 added both the mobile
range model and inline renderer; #612 retained notes in
`CitationViewer`; #628 changed the web note editor only. The inspected
current-dev rendering path and pure protobuf/range/sentinel tests do not
reproduce the reported model failure. Device rendering remains
unverified, so an older installed bundle is the supported explanation,
not a confirmed observation of the user's installation. No `Fixes`
attribution is warranted.
- The first release containing #591 is `v0.2.0-nightly.146`. Publication
is confirmed in [Mobile release
43333842969](https://github.com/itsoltech/canopy/actions/runs/43333842969):
Android OTA group `e48b25a0-804b-417e-a044-a528b9cb526e`, update
`01a1d239-0f22-7654-ad93-bbfc752d4c00`.
- The later [nightly.147
publication](https://github.com/itsoltech/canopy/actions/runs/43342358688)
is also confirmed: Android OTA group
[`1c21f61a-57a6-4dc3-ba1d-43d357c3d3ef`](https://expo.dev/accounts/itsol/projects/canopy-mobile/updates/1c21f61a-57a6-4dc3-ba1d-43d357c3d3ef),
update `01a1d274-0b11-71a1-9aa6-37106c5b9608`, commit
`31c7f87825b9756d8b1adf677f506519f248f770`. Both Android updates target
runtime `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. A compatible nightly
installation needs to run that OTA or later; a different native runtime
needs a matching build rather than that OTA. Updating desktop alone does
not update the mobile JS bundle.

Related: #591, #612, #628

## Verification

- Passed with `nice -n 19`: install, generated-code check, final-head
typecheck, lint, formatting check, web build, and the full test
inventory through the repository's four `check:tmp` shards: **2753 pass,
166 skip, zero failures**, 513 files, and no test temp leftovers. Shards
1–3 used the standard command; shard 4 passed with `--isolate
--parallel=2`.
- The default local shard 4 twice failed the unchanged startup recovery
test in `prompt-after-turn-end.test.ts` (`backgroundTasks`: expected 2,
received 1). Its entire file passed separately (6 tests), and the full
shard passed with Bun's built-in file isolation. No assertions or
gateway code were changed. The exact interference between files was not
investigated in this mobile change. [Standard GitHub
CI](https://github.com/itsoltech/canopy/actions/runs/43418493981) is
green on `2be705574aeb9b2c6d8785f59af95a81da4211e4`, including all four
default test shards, static checks and builds.
- Tests cover the reported two-note message after protobuf decoding
(including `start: 0`), citation-only and adjacent tokens, reversed
quote order, UTF-16 offsets around emoji and attachments, legacy queue
conversion, truncated labels, and full multiline notes. No UI tests
added.
- `expo-updates fingerprint:generate` before/after JSON comparisons are
empty for both platforms: iOS
`74705db3a68907bc28379bb9b1080a227bc0755b`; Android
`7d38be8f5c9bf842d62060c75820a206f99c87e3` (same local configuration and
environment).
- Device check unavailable: MacStudio returned `Device list failed:
Could not communicate with device support. Try refreshing devices.`
Refreshing once and attempting `device_open` for the requested Android
device returned the same error. No other device session was touched, no
EAS build or OTA was started, and native visual/layout behavior is
unverified.

## Copy audit

No UI copy changed. Existing `Citation`, `Copy quote` and source actions
remain unchanged; labels and notes retain their existing presentation.
The helper tests verify label truncation and unabridged notes, but do
not replace a visual check.
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.

1 participant