Skip to content

Conversation

@coodos
Copy link
Contributor

@coodos coodos commented Jan 27, 2026

Description of change

  1. Transactions header uses flex-col sm:flex-row and gap-3 so the title and actions stack on small screens and sit in one row on larger ones.
    Action buttons sit in a flex flex-wrap gap-2 container so they wrap instead of forcing horizontal scroll.

  2. handleAccountContextChange checks semantic equality (contextChanged).
    If type and id are unchanged, it returns without calling setAccountContext, so the effect that clears allTransactions and transactionOffset does not run and the list stays visible.

  3. Search still matches only name and handle (not ename).
    A numeric relevance is computed in SQL: exact match → 0, prefix match → 1, partial match → 2.
    Results are ordered by that relevance, then by user.name.
    eCurrency-api build completes successfully.

Issue Number

closes #712
closes #711
closes #709
closes #708
closes #695

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed group account context validation to properly handle loading states and preserve selected context
    • Eliminated unnecessary state updates and navigation when re-selecting the same account context
  • Refactor

    • Enhanced user search with improved relevance ranking for more accurate results

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Warning

Rate limit exceeded

@coodos has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 55 seconds before requesting another review.

⌛ 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.

📝 Walkthrough

Walkthrough

This PR addresses multiple issues in the eCurrency application: implementing fuzzy search with relevance-based sorting in UserService, fixing transaction history clearing on redundant account selection, preserving group account context across page refreshes, and improving mobile responsiveness by adjusting Transactions header layout.

Changes

Cohort / File(s) Change Summary
Fuzzy search with relevance sorting
platforms/eCurrency-api/src/services/UserService.ts
Enhanced searchUsers to prioritize results by relevance using CASE-driven scoring (0=exact match, 1=prefix match, 2=partial match). Normalized search terms, introduced pattern-based filtering, and added ordering by relevance then name.
Context validation and navigation
platforms/eCurrency/client/src/pages/currency-detail.tsx, platforms/eCurrency/client/src/pages/dashboard.tsx
Added guards for group account context validation to treat context as valid when groups are loading (undefined). Refactored currency-detail to perform semantic comparison before context changes and consistently navigate to dashboard, preventing unnecessary state updates and transaction history clearing.
Responsive layout adjustment
platforms/eCurrency/client/src/pages/currency-detail.tsx
Adjusted Transactions header layout classes to improve responsiveness on medium and small screens.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sosweetham
  • xPathin

Poem

🐰 Fuzzy search now ranks with care,
Exact matches float to the air,
Groups persist through refresh's dance,
Transactions stay—no accidental chance,
Mobile screens at last breathe free! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'fix: ecurrency issues' is too vague and generic, providing no meaningful information about the specific changes made. Replace with a more specific title describing the primary changes, e.g., 'fix: improve search relevance, prevent transaction history clear, and fix responsive layout'
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.
Out of Scope Changes check ❓ Inconclusive Issue #709 regarding UTC to local time zone conversion is not implemented in the provided changes, yet is listed as a closed issue. Clarify if #709 is addressed by the changes or if it should be removed from the closed issues list, as the modifications don't include timestamp timezone conversion.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers all required template sections with clear explanations of changes, linked issues, change type, and a completed checklist.
Linked Issues check ✅ Passed All code changes address the linked issues: search relevance sorting [#708], preventing transaction history clear on same account selection [#711], responsive layout for action buttons [#712], and preserving group account selection on refresh [#695].

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


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@platforms/eCurrency/client/src/pages/currency-detail.tsx`:
- Around line 146-152: The current semantic comparison sets contextChanged
incorrectly when finalContext is null; update the logic around accountContext
and finalContext so that when both are null it returns no change. Specifically,
in the code that computes contextChanged (referencing accountContext and
finalContext), add an explicit guard: if finalContext === null && accountContext
=== null then contextChanged = false; otherwise perform the existing null-safe
comparisons (compare finalContext.type and finalContext.id to
accountContext.type and accountContext.id). This ensures re-selecting the same
(null) context does not trigger an update.
🧹 Nitpick comments (2)
platforms/eCurrency-api/src/services/UserService.ts (1)

51-53: LIKE pattern special characters are not escaped.

If the search query contains SQL LIKE wildcards (% or _), they will be interpreted as pattern characters rather than literal characters. For example, searching for test_user would match test1user, testAuser, etc.

Consider escaping these characters:

♻️ Suggested fix
 async searchUsers(query: string, limit: number = 10): Promise<User[]> {
     const q = query.trim().toLowerCase();
+    const escaped = q.replace(/[%_]/g, '\\$&');
-    const patternPartial = `%${q}%`;
-    const patternPrefix = `${q}%`;
+    const patternPartial = `%${escaped}%`;
+    const patternPrefix = `${escaped}%`;

Also update the CASE statement to use escaped patterns for consistency.

platforms/eCurrency/client/src/pages/dashboard.tsx (1)

86-95: Missing semantic comparison optimization present in currency-detail.tsx.

The handleAccountContextChange function in currency-detail.tsx (lines 146-152) includes a semantic comparison that returns early if the context hasn't actually changed, preventing unnecessary transaction history clearing. This optimization is absent here, meaning clicking the currently selected account in the dashboard will still trigger state updates and clear the transaction list (issue #711).

Consider applying the same pattern here for consistency:

♻️ Suggested fix
 const handleAccountContextChange = (context: { type: "user" | "group"; id: string } | null) => {
   // If null is passed, default to user account
   const finalContext = context || (user ? { type: "user" as const, id: user.id } : null);
+
+  // Check if context actually changed (semantic comparison)
+  const contextChanged = !accountContext ||
+    accountContext.type !== finalContext?.type ||
+    accountContext.id !== finalContext?.id;
+
+  // Only update state and storage when context meaningfully changed
+  if (!contextChanged) return;
+
   setAccountContext(finalContext);

@coodos coodos merged commit 0aff235 into main Jan 27, 2026
4 checks passed
@coodos coodos deleted the chore/fix-ecurrency-issues branch January 27, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment