Skip to content

feat: Review page — batch confirm/reject categorizations by confidence#16

Merged
kayodebristol merged 5 commits into
mainfrom
copilot/feat-review-page-batch-confirm-reject-categorizati
Apr 3, 2026
Merged

feat: Review page — batch confirm/reject categorizations by confidence#16
kayodebristol merged 5 commits into
mainfrom
copilot/feat-review-page-batch-confirm-reject-categorizati

Conversation

Copilot AI commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Implements the missing Review.svelte component for the financial-advisor plugin. The route was already registered in index.ts but the component file did not exist.

What's in the page

  • Unconfirmed-only queue — filters to userConfirmed === false category inferences, sorted by confidence ascending (lowest certainty first)
  • Statistics bar — live counters for total / pending / auto-confirmed / user-confirmed / user-corrected
  • Filter by rule strategy — scopes the queue to a single inference rule (fa-recurring-amount, fa-vendor-clustering, fa-refund-detection, fa-tax-variance)
  • Batch confirm — per-row checkboxes + select-all; "Confirm N Selected" button writes userConfirmed: true to each inference via infCollection.put() with optimistic local state update
  • Single reject — opens a dialog pre-populated with the suggested category; correction saved as sourceId: 'user', confidence: 1.0, userConfirmed: true
  • Decision chain expansion — ▼/▲ toggle per row fetches ctx.inference.getDecisionChain(inf.id) and renders the numbered step list alongside reasoning/rule/confidence metadata

Key shape of the reject write

const updated: TransactionInference = {
  ...inf,
  value: rejectCategory,
  confidence: 1.0,
  reasoning: 'Manually set by user.',
  sourceId: 'user',
  userConfirmed: true,
  updatedAt: now,
};
await infCollection.put(inf.id, updated);

Styling follows the same CSS custom-property tokens and component patterns as Transactions.svelte.

Copilot AI changed the title [WIP] Add review page for batch confirm and reject categorizations feat: Review page — batch confirm/reject categorizations by confidence Apr 1, 2026
Copilot AI requested a review from kayodebristol April 1, 2026 23:52
@kayodebristol kayodebristol requested a review from Copilot April 2, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds the missing Review.svelte page for the financial-advisor plugin, enabling users to review and batch-confirm or correct low-confidence category inferences already produced/stored in fa-transaction-inferences.

Changes:

  • Introduces an unconfirmed-only review queue sorted by confidence (lowest first), with rule-strategy filtering.
  • Adds batch confirm flow (multi-select + select-all) that writes userConfirmed: true back to the inferences collection.
  • Adds per-row reject/correct dialog that overwrites the inference with a user-sourced, confidence-1.0 correction and supports decision-chain expansion.

Comment thread plugins/financial-advisor/src/pages/Review.svelte Outdated
if (!infCollection || !ctx || selectedIds.size === 0) return;
batchConfirming = true;
const now = new Date().toISOString();
const toConfirm = allInferences.filter(inf => selectedIds.has(inf.id));

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

batchConfirm() builds toConfirm from allInferences.filter(inf => selectedIds.has(inf.id)). Because selectedIds can include items not currently visible under the active filterStrategy, clicking “Confirm N Selected” can end up confirming hidden rows (and the “N” shown is selectedIds.size, not the visible selection count). Consider either clearing selectedIds when filterStrategy changes, or deriving a selectedVisibleIds set from unconfirmedRows and using that both for the button count and for toConfirm.

Suggested change
const toConfirm = allInferences.filter(inf => selectedIds.has(inf.id));
const toConfirm = unconfirmedRows
.filter(row => selectedIds.has(row.inf.id))
.map(row => row.inf);

Copilot uses AI. Check for mistakes.
FA_TRANSACTIONS_COLLECTION,
FA_INFERENCES_COLLECTION,
confidenceLevel,
generateInferenceId,

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

generateInferenceId is imported but never used in this component. Removing unused imports keeps the file easier to maintain and avoids confusion about intended behavior.

Suggested change
generateInferenceId,

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +79
// ── Derived: inference map keyed by transactionId ────────────────────────
const inferenceMap = $derived(
new Map<string, TransactionInference>(
allInferences
.filter(inf => inf.field === 'category')
.map(inf => [inf.transactionId, inf]),
),
);

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

inferenceMap is defined but not referenced anywhere in this page. If it’s leftover from copying Transactions.svelte, it should be removed; if it’s intended to be used, wire it into the row building logic to avoid dead derived state.

Suggested change
// ── Derived: inference map keyed by transactionId ────────────────────────
const inferenceMap = $derived(
new Map<string, TransactionInference>(
allInferences
.filter(inf => inf.field === 'category')
.map(inf => [inf.transactionId, inf]),
),
);

Copilot uses AI. Check for mistakes.
Comment thread plugins/financial-advisor/src/pages/Review.svelte Outdated

@kayodebristol kayodebristol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto-approved: CI green + code review complete.

@kayodebristol kayodebristol marked this pull request as ready for review April 3, 2026 23:53
@kayodebristol kayodebristol merged commit 68b121f into main Apr 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Review page — batch confirm/reject categorizations by confidence

3 participants