Skip to content

feat(ai): add AIReconciliationPanel human-in-the-loop component#244

Merged
wreiske merged 4 commits into
mainfrom
feat/ai-reconciliation-panel
Jun 6, 2026
Merged

feat(ai): add AIReconciliationPanel human-in-the-loop component#244
wreiske merged 4 commits into
mainfrom
feat/ai-reconciliation-panel

Conversation

@wreiske
Copy link
Copy Markdown
Member

@wreiske wreiske commented May 28, 2026

Summary

Adds a new AIReconciliationPanel component under src/components/AI/ — a generic "human-in-the-loop" review surface for AI-proposed field changes (e.g. profile updates extracted by DocumentScanner).

Features

  • Field-level proposals: Renders a list of current → proposed diffs and lets the user accept / reject / edit each one individually.
  • Confidence-based defaults: Rows default to checked for high/medium confidence and unchecked for low. Numeric confidence (0–1) or explicit confidenceLevel (high/medium/low) are both supported.
  • Inline editors: Pass renderEditor per proposal to allow the user to tweak the AI's value before applying.
  • Bulk actions: One-click accept-all / reject-all toggle.
  • Two variants: panel (inline card) and modal (wraps in <Modal> from this lib).
  • Equality filter: Drops cosmetic-only diffs (case, whitespace, null vs '', Date epoch, JSON-equivalent objects) so callers can pass every candidate field without pre-filtering.
  • Accessibility: role="alert", aria-live, labeled checkboxes, keyboard shortcut to submit.
  • onApply returns the accepted set with { id, value } so callers persist exactly what the human approved.

Use cases

  • Document scanner suggesting profile updates from a scanned ID / medical card
  • CSV import suggesting column → field mappings
  • AI-generated form drafts that the user reviews before saving
  • Any "AI proposes, human approves" workflow

Files

  • src/components/AI/Reconciliation.tsx — implementation
  • src/components/AI/Reconciliation.stories.tsx — Storybook stories
  • src/components/AI/Reconciliation.test.tsx — unit tests
  • src/components/AI/index.ts — re-export

Consumer

Wired up in bluehive-dot/imports/ui/DocumentUploadScanner.tsx to review AI-extracted CDL / DOT-medical fields. The consumer relies on the panel allowing every row to be unchecked (human-in-the-loop override).

A reusable panel + modal for letting users review, edit, and approve AI-proposed field changes (e.g. profile updates extracted by DocumentScanner). Includes confidence-based defaults, inline editors, bulk actions, keyboard shortcut, and full a11y. DocumentScanner now recommends pairing with it in its JSDoc.
Copilot AI review requested due to automatic review settings May 28, 2026 00:34
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 28, 2026

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 29a3d8f
Status: ✅  Deploy successful!
Preview URL: https://14eba0b0.ui-6d0.pages.dev
Branch Preview URL: https://feat-ai-reconciliation-panel.ui-6d0.pages.dev

View logs

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new AIReconciliationPanel component under src/components/AI/ to provide a reusable “human-in-the-loop” UI for reviewing, editing, and accepting/rejecting AI-proposed field changes, plus exports and supporting Storybook/tests. Also adds a DocumentScanner doc tip recommending the new panel for confirming extracted structured fields.

Changes:

  • Added AIReconciliationPanel implementation with proposal diff filtering, confidence defaults, grouping, bulk select, inline editing, and modal/panel variants.
  • Added Storybook stories and Vitest tests for the new component.
  • Re-exported the new component/types from src/components/AI/index.ts and referenced it in DocumentScanner docs.

Reviewed changes

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

Show a summary per file
File Description
src/components/DocumentScanner/index.ts Adds docs guidance to pair DocumentScanner with AIReconciliationPanel for confirmation workflows.
src/components/AI/Reconciliation.tsx Implements the new AI reconciliation panel (panel + modal variants).
src/components/AI/Reconciliation.test.tsx Adds unit coverage for filtering/default selection/bulk actions/editing/modal behavior.
src/components/AI/Reconciliation.stories.tsx Adds Storybook stories demonstrating key variants and behaviors.
src/components/AI/index.ts Re-exports the new component utilities/types from the AI module barrel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/AI/Reconciliation.tsx
Comment thread src/components/AI/Reconciliation.tsx Outdated
Comment thread src/components/AI/Reconciliation.tsx
Comment thread src/components/AI/Reconciliation.tsx Outdated
Comment thread src/components/AI/Reconciliation.tsx
- Use sorted-key stable stringify in defaultReconciliationIsEqual so JSON-equivalent objects with differing key order compare equal.

- Reset internal row state on any meaningful proposal change (proposed value, defaultAccepted, required, confidence), not just on id-set changes.

- Defensively default missing row state during render and in row mutators so the component does not crash when proposals add new ids before the reset effect runs.

- Add Cmd/Ctrl+Enter keyboard shortcut to submit (Apply) so the keyboard story matches the docs.

- Add Reconciliation-specific utility strings to miewebUISafelist so Tailwind 3 consumers using the preset get the right styles.
Copilot AI review requested due to automatic review settings May 28, 2026 01:13
@wreiske wreiske force-pushed the feat/ai-reconciliation-panel branch from 1786f27 to b6eb51a Compare May 28, 2026 01:14
Copy link
Copy Markdown

Copilot AI left a comment

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 6 out of 6 changed files in this pull request and generated 5 comments.

Comment thread src/components/AI/Reconciliation.tsx
Comment thread src/components/AI/Reconciliation.tsx Outdated
Comment thread src/components/AI/Reconciliation.tsx
Comment thread src/tailwind-preset.ts
Comment thread src/components/AI/Reconciliation.stories.tsx
- Make stableStringify cycle-safe and wrap stateSignature in safeStableStringify so non-serializable proposal values cannot crash render.

- Replace AIReconciliationPanelProps with a discriminated union: panel variant forbids open/onOpenChange, modal variant requires them at the type level.

- Add role=status alongside aria-live=polite on the bulk-selection counter so the dynamic count is an actual live region (the container remains role=group).

- Pass onNothingToReconcile to the NothingToReconcile story so docs and behavior match.

- Add ring-1, last:border-b-0, border-dashed, text-[11px] to miewebUISafelist.
@wreiske wreiske merged commit 477798c into main Jun 6, 2026
10 checks passed
@wreiske wreiske deleted the feat/ai-reconciliation-panel branch June 6, 2026 09:18
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