Skip to content

fix: citation numbering gaps, flag-click annotation reset, stale client directory - #52

Merged
crewcricle merged 1 commit into
mainfrom
fix/trust-bugs-flag-click-citations-directory
Aug 8, 2026
Merged

fix: citation numbering gaps, flag-click annotation reset, stale client directory#52
crewcricle merged 1 commit into
mainfrom
fix/trust-bugs-flag-click-citations-directory

Conversation

@rprabhat

@rprabhat rprabhat commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Items #1, #2 (re-scoped), #3 from the consolidated fix plan — bundled because each is the same failure class: the product shows the user something that doesn't add up.

  • Answer transparency & explainability #3 - Citation numbering gap. _parse_citations only ever returned entries for numbers the model happened to cite ([1][2][4][5] stayed [1][2][4][5]). New _renumber_citations remaps both the rendered answer text and the citations array to a contiguous 1..N sequence in first-appearance order. Applies to newly generated answers only - existing stored conversations keep their original numbering.
  • Backend audit: latency, agent cost, answer correctness & personalisation improvements #1 - Flag-click removes the underline instead of explaining it. Root cause: AnnotatableMarkdown's visibleThreads was rebuilt with a plain .filter() on every render, breaking the referential stability RecogitoLayer's setAnnotations effect depends on - triggering a full highlight-layer replace/rebuild far more often than needed, including on renders that land mid-click. Fixed by memoizing on [threads, showResolved].
  • Ports-and-adapters backend refactor + LangGraph agent loop #2 - Workspace Clients directory shows 0 activity for clients with real work on file. Re-scoped mid-implementation: the original plan called for a data backfill, but a dry-run of the existing scripts/backfill_engagements.py against prd found zero unlinked buckets - the data isn't missing. Actual cause: WorkspaceClientsTable's fetch only ran once on mount, so Radix's persistent TabsContent never learned about activity created after the tab was first visited. Workspace's Tabs is now controlled and hands the table a fresh key each time the Clients tab is selected, forcing a refetch.

Verification

  • Backend: 842 tests pass (4 new, covering renumbering - gap-closing, first-appearance ordering, multi-number brackets, no-op when nothing cited).
  • Frontend: tsc --noEmit and eslint clean.
  • Live-verified in browser (demo login, Nepean Tradie Accountants persona, the exact conversation with the citation gap the accountant review flagged): clicked two separate flagged claims - both opened the "Needs review before relying on this" popup with full detail, and the underline stayed intact after closing each popup. Confirms the flag-click fix works end-to-end, not just in isolation.

Reviewer notes

🤖 Generated with Claude Code

…nt directory

Three trust-integrity bugs from the accountant audit round three,
bundled together since each is the same failure class: the product
shows the user something that doesn't add up.

- Citation numbers could skip a number (e.g. [1][2][4][5]) because
  _parse_citations only ever returned entries for numbers the model
  happened to cite, never renumbering to a contiguous sequence.
  _renumber_citations now remaps both the rendered answer text and the
  citations array to first-appearance order, so what's on screen is
  always 1..N. Applies to newly generated answers only; existing
  stored conversations keep whatever numbering they were generated
  with.

- Clicking a flagged claim sometimes cleared its underline instead of
  opening the detail popup. Root cause: AnnotatableMarkdown's
  visibleThreads was rebuilt with a plain .filter() on every render,
  breaking the referential stability RecogitoLayer's setAnnotations
  effect depends on - triggering a full highlight-layer
  replace/rebuild (Recogito's `replace: true`) far more often than
  actually needed, including on renders that land mid-click. Memoized
  to fire only when threads/showResolved genuinely change. Verified
  live: repeated clicks on multiple flagged claims now consistently
  open the detail popup with the underline intact after closing it.

- Workspace's Clients directory showed 0 conversations/documents for
  clients with real, freshly-asked questions. Root cause turned out
  not to be missing engagement_id data (a prod dry-run of the existing
  backfill script found nothing to backfill) but a stale client-side
  fetch: WorkspaceClientsTable's effect only ran once on mount, so
  Radix's persistent TabsContent never learned about activity created
  after the tab was first visited. Workspace's Tabs is now controlled
  and hands WorkspaceClientsTable a fresh key each time the Clients
  tab is actually selected, forcing a refetch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
taxflow-dashboard Ready Ready Preview Aug 8, 2026 8:00am

@crewcricle
crewcricle merged commit 4761075 into main Aug 8, 2026
7 checks passed
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.

2 participants