Skip to content

TEC-58: admin-web finance/support exception cockpit#22

Merged
imKXNNY merged 2 commits into
mainfrom
feature/tec-58-finance-exception-cockpit
Apr 14, 2026
Merged

TEC-58: admin-web finance/support exception cockpit#22
imKXNNY merged 2 commits into
mainfrom
feature/tec-58-finance-exception-cockpit

Conversation

@imKXNNY

@imKXNNY imKXNNY commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

Summary\n- add finance/support exception queue module in admin-web, derived from billing dispute signals with bounded anomaly types\n- render finance/support section on operator dashboard with loading/empty/error/loaded states and triage actions (acknowledge, follow-up, route to dispute/manual review)\n- extend dashboard presenter tests and add focused finance-exception action tests\n- update README current-state notes to reflect the new rendered capability and bounded backend seam\n\n## Verification\n- pnpm --filter @quickwerk/admin-web test\n- pnpm --filter @quickwerk/admin-web typecheck

Summary by CodeRabbit

  • New Features

    • Added finance/support exception queue to the admin dashboard.
    • Exception entries display billing dispute anomalies with triage actions: acknowledge, follow-up, and route to dispute/manual review.
    • Queue sections now render all loading, empty, error, and loaded states with inline operator actions.
  • Documentation

    • Updated documentation to reflect the new finance exception queue section.
  • Tests

    • Added test coverage for finance exception state management and queue operations.

- add finance exception queue state/actions backed by billing dispute signals

- render dashboard finance/support section with triage actions

- expand presenter/tests and update README current-state notes

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@coderabbitai[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 27 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 27 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d8ace73-438c-4513-8b02-01fbfd3b7975

📥 Commits

Reviewing files that changed from the base of the PR and between 31467c0 and c6c748a.

📒 Files selected for processing (4)
  • apps/admin-web/src/app/page.js
  • apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts
  • apps/admin-web/src/features/finance-exceptions/finance-exception-state.ts
  • packages/api-client/src/index.ts
📝 Walkthrough

Walkthrough

This PR introduces a finance/support exception queue to the admin dashboard, adding state management types, data-fetching and triage logic, UI components for operator actions, and comprehensive test coverage across the new feature layers.

Changes

Cohort / File(s) Summary
Documentation
README.md
Updated descriptions to document the new finance/support exception queue derived from billing disputes, with bounded anomaly typing and triage actions; clarified dashboard rendering of all three operator sections with explicit state handling.
State & Types
apps/admin-web/src/features/finance-exceptions/finance-exception-state.ts
Added new exported types and factory functions for finance exception state machine: FinanceExceptionState, FinanceExceptionSummary, FinanceExceptionTriageActionType, FinanceExceptionQueueAction, and state constructors (createFinanceLoadingState, createFinanceEmptyState, createFinanceErrorState, createFinanceLoadedState).
Business Logic
apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts
Added core functions for loading finance exception state from billing disputes and submitting triage transitions via API; includes dispute filtering, anomaly classification, status mapping, and error handling for state transitions.
Presentation Layer
apps/admin-web/src/features/dashboard/dashboard-presenter.ts
Added describeFinanceExceptionQueue() presenter function to generate queue status summaries (badge, headline, detail) mirroring existing verification/dispute queue presenters.
Page & UI
apps/admin-web/src/app/page.js
Extended admin dashboard to import finance exception utilities, added server action triageFinanceExceptionAction to handle triage submissions, and added FinanceExceptionSection UI component with operator action buttons and state rendering.
Test Coverage
apps/admin-web/src/features/dashboard/dashboard-presenter.test.ts, apps/admin-web/src/features/finance-exceptions/finance-exception-actions.test.ts
Added tests for presenter function covering all state variants; added comprehensive action tests validating state loading from disputes, filtering, error handling, and triage workflow transitions.

Sequence Diagram

sequenceDiagram
    participant User as Operator
    participant Page as Admin Page
    participant Action as Finance Exception Action
    participant API as Platform API
    participant State as State Machine

    User->>Page: View admin dashboard
    Page->>Action: loadFinanceExceptionState(sessionToken)
    Action->>API: GET /disputes?category=billing
    API-->>Action: Dispute records
    Action->>State: Create FinanceExceptionState.loaded
    State-->>Action: State with exceptions
    Action-->>Page: Return finance state
    Page->>Page: Render FinanceExceptionSection with exceptions

    User->>Page: Click triage action (e.g., "Follow-up")
    Page->>Page: Submit form (exceptionId, actionType)
    Page->>Action: triageFinanceExceptionAction(state, exceptionId, actionType)
    Action->>State: Validate & locate exception
    State-->>Action: Found exception
    Action->>API: PATCH /disputes/{disputeId}/start-review
    API-->>Action: Updated dispute
    Action->>State: Update exception with new status
    State-->>Action: Updated state
    Action-->>Page: Return refreshed state
    Page->>Page: Revalidate & re-render dashboard
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Finance queues now bloom with care,
Disputes sorted, triaaged with flair!
States load, transitions flow,
Operators act, watch exceptions go—
A queue reborn, no more delays! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a finance/support exception cockpit feature to the admin-web application, which is well-supported by all the file changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/tec-58-finance-exception-cockpit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/admin-web/src/app/page.js`:
- Around line 93-97: The handler currently defaults actionType to
'routeToDispute', allowing malformed submissions to perform writes; change the
code to not default actionType (use String(formData.get('actionType') ?? '') or
simply formData.get('actionType')) and validate that actionType is one of the
allowed values ('acknowledge','followUp','routeToDispute'); if it's missing or
unknown, fail closed by returning an error/400 or throwing instead of proceeding
with the write. Locate the validation around the actionType and exceptionId
variables in the request handler and replace the defaulting behavior with an
explicit rejection on invalid/missing actionType.
- Around line 100-113: The server action currently ignores the return value of
submitFinanceExceptionTriage() and always calls revalidatePath('/'), causing
errors (queueAction.status === 'error') to be discarded; change the flow in the
handler that calls loadFinanceExceptionState and submitFinanceExceptionTriage so
you capture the returned state (e.g., const newState = await
submitFinanceExceptionTriage(...)), check newState.queueAction.status for
'error' and return that state (or throw/propagate it) instead of immediately
calling revalidatePath('/'); alternatively wire the action into the UI with
useActionState so describeFinanceExceptionQueue can render the error—ensure you
only call revalidatePath('/') on success.

In `@apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts`:
- Around line 91-102: The mapper toFinanceExceptionSummary is fabricating
participant IDs ('unknown-provider' / 'unknown-customer') which should be
nullable; change the mapping in toFinanceExceptionSummary so providerUserId and
customerUserId are set to null when the reporterRole does not match instead of
using placeholder strings, keep anomalyType/anomalyReason/disputeId mapping the
same, and ensure the FinanceExceptionSummary type (and any consumers like the
UI) treat these fields as nullable so absent parties are hidden until a proper
participant lookup enriches them.
- Around line 300-322: Both followUp and routeToDispute currently call
createStartReviewDisputeRequest/transitionDispute and produce the same state;
make them distinct by either (A) introducing a separate backend/state transition
for routing (e.g., implement createRouteToDisputeRequest(sessionToken,
disputeId) and call transitionDispute with that request so the returned dispute
or status differs, or (B) collapse the UI to a single action until the separate
transition exists. Concretely: update the routeToDispute handler (the code path
that currently calls createStartReviewDisputeRequest and transitionDispute) to
call a new request builder createRouteToDisputeRequest and/or pass a distinct
actionType (e.g., 'route' vs 'followUp') into
replaceDisputeInState/replaceDisputeInState handling so the resulting
triagingState/dispute differs; if you choose to collapse, remove one button in
the UI and unify callers to the existing createStartReviewDisputeRequest path.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7cb6e9ed-fbbb-4998-b7e7-177b58dc1fe0

📥 Commits

Reviewing files that changed from the base of the PR and between 7d0ace4 and 31467c0.

📒 Files selected for processing (7)
  • README.md
  • apps/admin-web/src/app/page.js
  • apps/admin-web/src/features/dashboard/dashboard-presenter.test.ts
  • apps/admin-web/src/features/dashboard/dashboard-presenter.ts
  • apps/admin-web/src/features/finance-exceptions/finance-exception-actions.test.ts
  • apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts
  • apps/admin-web/src/features/finance-exceptions/finance-exception-state.ts

Comment thread apps/admin-web/src/app/page.js Outdated
Comment thread apps/admin-web/src/app/page.js
Comment thread apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts Outdated
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 5 file(s) based on 4 unresolved review comments.

Files modified:

  • apps/admin-web/next-env.d.ts
  • apps/admin-web/src/app/page.js
  • apps/admin-web/src/features/finance-exceptions/finance-exception-actions.ts
  • apps/admin-web/src/features/finance-exceptions/finance-exception-state.ts
  • packages/api-client/src/index.ts

Commit: c6c748a1807a063e78adc8da37ec6972acf8a5c4

The changes have been pushed to the feature/tec-58-finance-exception-cockpit branch.

Time taken: 5m 59s

Fixed 5 file(s) based on 4 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@imKXNNY imKXNNY merged commit 1b6190d into main Apr 14, 2026
2 checks passed
@imKXNNY imKXNNY deleted the feature/tec-58-finance-exception-cockpit branch April 14, 2026 22:03
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