Skip to content

feat: DeepCitation branding, isImpreciseLocation refactor, truncateMiddle utility#388

Merged
bensonwong merged 9 commits intomainfrom
feat/cdn-a11y-i18n-caching
Mar 30, 2026
Merged

feat: DeepCitation branding, isImpreciseLocation refactor, truncateMiddle utility#388
bensonwong merged 9 commits intomainfrom
feat/cdn-a11y-i18n-caching

Conversation

@bensonwong
Copy link
Copy Markdown
Collaborator

@bensonwong bensonwong commented Mar 30, 2026

Summary

  • DeepCitation branding: Prefix status.verified, status.partialMatch, status.notFound and aria.statusSuffix.* labels with "DeepCitation" in default messages and all locale files (es, fr, vi). Updates all test assertions to match.
  • isImpreciseLocation refactor: Move imprecise location detection from inline EvidenceTray derivation to a pre-computed isImpreciseLocation?: boolean flag on the Verification type, set by the verification engine.
  • truncateMiddle utility: New truncateMiddle(str, maxLength) function in react/utils.ts, exported from react/index.ts. Includes edge-case guards for maxLength <= 1 and unit tests.
  • URL chip truncation: Remove hardcoded max-w-[200px] from UrlCitationComponent chip, add min-w-0 for proper flex-based CSS truncation. Remove MAX_URL_DISPLAY_LENGTH constant from VerificationLog, pass Infinity to let CSS handle it.

Test plan

  • bun run test — 1655 tests pass (7 new for truncateMiddle)
  • bun run lint — clean
  • Visual check: URL citation chips truncate naturally via CSS in popover and drawer contexts
  • Visual check: status labels show "DeepCitation Verified" / "DeepCitation Partial Match" / "DeepCitation Not Found" in chip UI
  • Screen reader check: ARIA status suffixes include "DeepCitation" prefix

Benson and others added 6 commits March 30, 2026 15:07
Remove max-w-[200px] and MAX_URL_DISPLAY_LENGTH constraints from citation
chips so text flows naturally within its container. Add min-w-0 for proper
flex-item text overflow. Export truncateMiddle() for consumers who need
middle-truncation (e.g. API keys, hashes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…denceTray

Instead of re-deriving imprecise location from citation fields in the
UI, read the pre-computed flag stamped by the verification engine.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prefix verified/partial-match/not-found status text with "DeepCitation"
for clearer product attribution in the UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…randing

Propagate the "DeepCitation" prefix to status labels in all locale
files (es, fr, vi), ARIA status suffixes for screen reader consistency,
and update test assertions to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The variable name and the JSDoc on the Verification type already
document the intent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix slice(-0) returning full string when maxLength=1, and negative half
when maxLength=0. Add unit tests covering edge cases. Also update stale
JSDoc comment in i18n.tsx.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

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

4 Skipped Deployments
Project Deployment Actions Updated (UTC)
agui-chat-deepcitation Ignored Ignored Preview Mar 30, 2026 8:57am
deepcitation-langchain-rag-chat Ignored Ignored Preview Mar 30, 2026 8:57am
mastra-rag-deepcitation Ignored Ignored Preview Mar 30, 2026 8:57am
nextjs-ai-sdk-deepcitation Ignored Ignored Preview Mar 30, 2026 8:57am

@claude
Copy link
Copy Markdown

claude bot commented Mar 30, 2026

PR Review: feat: DeepCitation branding, isImpreciseLocation refactor, truncateMiddle utility

Overall this is a well-scoped PR with solid test coverage. A few issues worth addressing before merge.


🔴 Breaking Change: isImpreciseLocation refactor (silent regression risk)

src/react/evidence/EvidenceTray.tsx / src/types/verification.ts

Moving from derived-in-UI to engine-supplied flag is architecturally correct, but it creates a silent regression: any Verification object that doesn't have isImpreciseLocation set (e.g. from a verification engine that hasn't been updated, or a cached/serialized response from before this change) will now silently render as if the location is precise, hiding the indicator.

The old derivation was always computable from existing citation data — this new approach requires the engine to opt-in. At minimum, consider whether a fallback derivation is needed for the transition:

// Backward-compatible fallback
const isImpreciseLocation =
  verification?.isImpreciseLocation === true
  ?? (status.isVerified && !isMiss && !isPartialMatch && (!hasPageNumber || !hasLineIds));

Or document explicitly in Verification.isImpreciseLocation's JSDoc that pre-existing responses will default to false (no indicator shown).


🟡 Mixed-language ARIA labels in localized files

src/react/locales/es.ts, fr.ts, vi.ts

The aria.statusSuffix.* keys now contain the English brand name inline with localized text:

"aria.statusSuffix.verified": "DeepCitation vérifiée",  // French
"aria.statusSuffix.verified": "DeepCitation verificado", // Spanish
"aria.statusSuffix.verified": "DeepCitation đã xác minh", // Vietnamese

Screen readers announce ARIA labels using the document/element language setting. An English proper noun ("DeepCitation") embedded in a French string will likely be mispronounced by French TTS engines. If the brand name must appear, the ARIA label template that uses the suffix (e.g. aria.citationWithStatus) is a better place to inject it once in English, keeping the suffix itself language-pure. Alternatively, if this is intentional brand policy, it should be called out explicitly.


🟡 truncateMiddle has no internal callers

src/react/utils.ts, src/react/index.ts

The function is exported as public API but not called anywhere in this PR. The URL chip truncation was migrated to CSS, and no other component uses it. The JSDoc also describes a use case ("API keys, IDs, and hashes") that doesn't match any current internal usage.

This isn't necessarily wrong — exporting a useful utility is fine — but it's worth confirming this is intentional public API surface (with the associated semver contract), rather than an artifact of a refactor that didn't fully land.


🟡 Infinity passed to maxDisplayLength

src/react/VerificationLog.tsx:485

maxDisplayLength={Infinity}

This works correctly if UrlCitationComponent passes maxDisplayLength to truncateMiddle, which short-circuits via str.length <= maxLength → always true when maxLength = Infinity. But it's worth a quick check that no downstream code does something like new Array(maxDisplayLength) or math that would produce NaN/Infinity artifacts. A named constant like NO_JS_TRUNCATION = Infinity or simply removing the prop (relying on a default) would make intent clearer.


✅ Positives

  • truncateMiddle tests are thorough — edge cases for maxLength ≤ 0, empty string, and boundary conditions are all covered. The implementation itself is correct.
  • CSS flex truncation is the right call — removing the hardcoded max-w-[200px] and relying on min-w-0 + CSS text-overflow: ellipsis is more responsive and correct for flex layouts.
  • Branding changes are consistent — all locales, ARIA strings, test assertions, and the JSDoc example in createTranslator are updated together. No missed spots.
  • isImpreciseLocation type placement — adding it to Verification (engine output) rather than deriving it in every UI component is the right long-term direction; the concern above is only about the migration path.

Summary of requested changes:

  1. Document or handle the backward-compatibility gap for isImpreciseLocation on pre-existing Verification objects.
  2. Revisit ARIA suffix strings in locale files for TTS/screen-reader correctness in non-English contexts.
  3. Clarify the intent of the truncateMiddle export (is this deliberate public API?) and update its JSDoc to reflect actual usage.

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

✅ Playwright Test Report

Status: Tests passed

📊 Download Report & Snapshots (see Artifacts section)

What's in the Visual Snapshots

The gallery includes visual snapshots for:

  • 🖥️ Desktop showcase (all variants × all states)
  • 📱 Mobile showcase (iPhone SE viewport)
  • 📟 Tablet showcase (iPad viewport)
  • 🔍 Popover states (verified, partial, not found)
  • 🔗 URL citation variants

Run ID: 23736348290

Benson and others added 2 commits March 30, 2026 15:54
Use truncateMiddle instead of end-truncation for citation titles so both
the beginning and end of text are preserved. Cap VerificationLog source
chips at 45 chars instead of Infinity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bensonwong bensonwong merged commit 6496627 into main Mar 30, 2026
6 checks passed
@bensonwong bensonwong deleted the feat/cdn-a11y-i18n-caching branch March 30, 2026 08:59
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