Skip to content

Refactor sync interval and update customer segment in various components - #7

Merged
mokoker merged 1 commit into
masterfrom
sprint11-26/ChangeOneStepRez
May 25, 2026
Merged

Refactor sync interval and update customer segment in various components#7
mokoker merged 1 commit into
masterfrom
sprint11-26/ChangeOneStepRez

Conversation

@tsimsekburgan

@tsimsekburgan tsimsekburgan commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Simplify the customer reservation workflow while speeding up chat/video sync and correcting a mock customer segment.

Bug Fixes:

  • Ensure reservation workflows include advisor type and use the correct customer segment in mock data.
  • Reduce sync throttling in chat- and video-related components so new events appear more promptly.

Enhancements:

  • Streamline appointment booking by creating the reservation instance when opening the modal and confirming it in a single step without a separate confirmation modal.
  • Provide clearer booking feedback by tracking per-advisor loading state and showing a spinner while initializing reservations.

Summary by CodeRabbit

  • Performance Improvements

    • Enhanced real-time chat message sync frequency for more responsive updates across chat interfaces.
  • Features

    • Streamlined booking flow: reservation confirmation now completes in a single step instead of requiring a separate confirmation step.
  • Data Updates

    • Updated customer segment classifications.

Review Change Stack

@tsimsekburgan
tsimsekburgan requested review from a team May 25, 2026 11:04
@sourcery-ai

sourcery-ai Bot commented May 25, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors the customer reservation workflow to start the reservation instance when opening the booking modal and confirm it directly on slot selection, removes the intermediate confirm-reservation modal and polling logic, adds loading feedback when opening a booking, speeds up chat sync intervals, and updates a mock customer segment value.

Sequence diagram for updated customer reservation workflow

sequenceDiagram
  participant Dashboard
  participant RezervationRuntime

  rect rgb(230,230,250)
    Dashboard->>RezervationRuntime: startInstance
    RezervationRuntime-->>Dashboard: { id: instanceId }
    Dashboard->>Dashboard: setBookModal(advisorKey, advisorType, instanceId)
  end

  rect rgb(230,250,230)
    Dashboard->>RezervationRuntime: runTransition(confirm-selection, instanceId, attributes)
    RezervationRuntime-->>Dashboard: confirmRes
    Dashboard->>Dashboard: extractWorkflowCurrentState(confirmRes.data)

    alt state !== active && state !== slot-unavailable && state !== ""
      loop until state is active or slot-unavailable
        Dashboard->>Dashboard: delay(320)
        Dashboard->>RezervationRuntime: getInstance(instanceId)
        RezervationRuntime-->>Dashboard: instanceData
        Dashboard->>Dashboard: extractWorkflowCurrentState(instanceData)
      end
    end

    alt state === slot-unavailable
      Dashboard->>Dashboard: toast("Bu slot artık müsait değil")
    else state === active || state === ""
      Dashboard->>Dashboard: setReservationSuccessModalOpen(true)
      Dashboard->>Dashboard: setBookModal(null)
    else
      Dashboard->>Dashboard: toast("Randevu tamamlanamadı")
    end
  end
Loading

File-Level Changes

Change Details Files
Refactor reservation workflow to start instances on modal open and confirm directly in the booking handler, removing the separate confirmation step and its polling logic.
  • Extend bookModal state to include a workflow instanceId and add openingBook state to track which advisor is being initialized.
  • Replace the old confirm-reservation state, polling effect, and transition handler with a simpler flow that starts the workflow instance when the booking modal opens.
  • Update the slot booking handler to run the confirm-selection transition on the existing instance, poll briefly for its terminal state, and drive success/error toasts and reservation refresh from that result.
  • Remove the dedicated confirm reservation summary modal and its associated rendering logic.
src/pages/customer/Dashboard.tsx
Add UI feedback when initializing a reservation and prevent duplicate booking actions per advisor while the workflow instance is being created.
  • Track the advisor key currently opening a booking and disable the "Randevu Al" button for that advisor while the reservation instance is being started.
  • Show a spinning RefreshCw icon instead of the CalendarDays icon while a booking is being initialized.
src/pages/customer/Dashboard.tsx
Speed up Matrix chat synchronization loops for customer, advisor, and video call contexts by reducing the minimum sync interval.
  • Lower the SYNC_MIN_INTERVAL_MS constant from 2000ms to 200ms in the video call chat component.
  • Lower the SYNC_MIN_INTERVAL_MS constant from 2000ms to 200ms in the advisor chat management page.
  • Lower the SYNC_MIN_INTERVAL_MS constant from 2000ms to 200ms in the customer chat page.
src/components/VideoCallMatrixChat.tsx
src/pages/advisor/ChatManagement.tsx
src/pages/customer/Chat.tsx
Adjust a mock customer's segment to reflect a different product tier in fixtures.
  • Change the segment value of the Abdurrahman Kiranli mock customer from "Private Plus" to "Private".
src/data/customers.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: caba0b6b-37e5-4b26-8178-cc1f1392c22c

📥 Commits

Reviewing files that changed from the base of the PR and between 3f913f5 and a980a28.

📒 Files selected for processing (5)
  • src/components/VideoCallMatrixChat.tsx
  • src/data/customers.ts
  • src/pages/advisor/ChatManagement.tsx
  • src/pages/customer/Chat.tsx
  • src/pages/customer/Dashboard.tsx

📝 Walkthrough

Walkthrough

This PR optimizes Matrix sync polling intervals from 2000ms to 200ms across chat components, and refactors the customer dashboard booking workflow from a two-step modal flow with polling confirmation to a single-step flow that creates the reservation instance on modal open and confirms via direct transition on user action. A test customer segment value is also updated.

Changes

Matrix Sync Polling Optimization

Layer / File(s) Summary
Sync interval reduction across chat components
src/components/VideoCallMatrixChat.tsx, src/pages/advisor/ChatManagement.tsx, src/pages/customer/Chat.tsx
SYNC_MIN_INTERVAL_MS reduced from 2000 to 200ms in video call and chat management components, tightening the minimum throttle delay between Matrix sync requests.

Dashboard Booking Flow Consolidation

Layer / File(s) Summary
Booking state structure and old flow removal
src/pages/customer/Dashboard.tsx
bookModal state extended with reservation instanceId and new openingBook async lifecycle flag; previous confirmReservation state, polling useEffect, transition handlers, and confirmation modal entirely removed.
Async booking initialization
src/pages/customer/Dashboard.tsx
openBookModal converted to async function that calls startInstance('rezervation'), validates the returned instanceId, sets bookModal state, and manages openingBook lifecycle with error handling and cleanup.
Booking confirmation and validation
src/pages/customer/Dashboard.tsx
handleBook now directly transitions the pre-created bookModal.instanceId via runTransition with 'confirm-selection' action; success (active or empty state) closes booking modal and opens success modal; slot-unavailable error shows message and returns without closing modal.
Button UI and feedback
src/pages/customer/Dashboard.tsx
Private Plus "Randevu Al" button updated to disable and display spinner when openingBook state matches the current booking key, providing visual feedback during async instance creation phase.
Customer test data update
src/data/customers.ts
Test customer with customerId '10928922766' segment value changed from 'Private Plus' to 'Private'.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • burgan-tech/morph-touch-ui#6: Related through customer data model and test fixture updates used alongside customer-facing feature changes.

Poem

🐰 Faster polls now race the wire,
Two steps merge to one desire,
Bookings flow from click to go—
No confirm delays, just swift say so!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sprint11-26/ChangeOneStepRez

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.

@mokoker
mokoker merged commit 6631a88 into master May 25, 2026
6 of 7 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The SYNC_MIN_INTERVAL_MS constant is now duplicated across VideoCallMatrixChat, ChatManagement, and customer/Chat; consider centralizing this in a shared config/module so future tuning only needs to happen in one place.
  • The handleBookSave flow contains several hard-coded polling parameters (14 iterations, 320ms delay, specific state checks) that mirror patterns used elsewhere; extracting this workflow-polling/transition logic into a reusable helper would make the behavior easier to tweak and reason about.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `SYNC_MIN_INTERVAL_MS` constant is now duplicated across `VideoCallMatrixChat`, `ChatManagement`, and `customer/Chat`; consider centralizing this in a shared config/module so future tuning only needs to happen in one place.
- The `handleBookSave` flow contains several hard-coded polling parameters (14 iterations, 320ms delay, specific state checks) that mirror patterns used elsewhere; extracting this workflow-polling/transition logic into a reusable helper would make the behavior easier to tweak and reason about.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the reservation booking flow in the Dashboard, moving instance creation to the start of the process and removing the intermediate summary modal. It also reduces the synchronization interval for chat components from 2000ms to 200ms. Feedback focuses on the significantly reduced polling timeout in the new booking logic, which may lead to errors, and the potential for high server load due to the aggressive chat synchronization frequency.

toast('Randevu oluşturuldu; onay için danışman ile iletişime geçin.', 'success');
let stateStr = extractWorkflowCurrentState(confirmRes.data);
if (stateStr !== 'active' && stateStr !== 'slot-unavailable') {
for (let i = 0; i < 14 && stateStr !== 'active' && stateStr !== 'slot-unavailable'; i += 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The polling timeout has been significantly reduced in this refactor. The previous implementation (removed useEffect) allowed for approximately 29 seconds of polling (45 attempts * 650ms). The new logic only allows for about 4.5 seconds (14 attempts * 320ms). If the backend process for confirming a reservation takes longer than 4.5 seconds, the user will receive a "Randevu tamamlanamadı" error even if the operation eventually succeeds. Consider increasing the number of attempts to match the previous timeout duration.

Suggested change
for (let i = 0; i < 14 && stateStr !== 'active' && stateStr !== 'slot-unavailable'; i += 1) {
for (let i = 0; i < 45 && stateStr !== 'active' && stateStr !== 'slot-unavailable'; i += 1) {

import { customerDisplayName, getCustomerName } from '../data/customers';

const SYNC_MIN_INTERVAL_MS = 2000;
const SYNC_MIN_INTERVAL_MS = 200;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The reduction of SYNC_MIN_INTERVAL_MS from 2000ms to 200ms is a significant change. While it improves responsiveness, it also increases the frequency of requests by 10x. Given the comment on line 28 of ChatManagement.tsx (and similar files) about avoiding "hammering the runtime", 200ms might be too aggressive for a long-polling loop, potentially leading to high server load if many clients are active simultaneously. Please consider if a slightly higher value (e.g., 500ms or 1000ms) would be a safer middle ground.

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