Skip to content

restart conversation#1489

Open
adityaKommunicate wants to merge 16 commits into
developmentfrom
restart-conversations-issue
Open

restart conversation#1489
adityaKommunicate wants to merge 16 commits into
developmentfrom
restart-conversations-issue

Conversation

@adityaKommunicate
Copy link
Copy Markdown

@adityaKommunicate adityaKommunicate commented Mar 17, 2026

What do you want to achieve?

  • Enable Restart Conversation and chat field after a conversation is resolved.

PR Checklist

  • I have tested it locally and all functionalities are working fine.
  • I have compared it with mocks and all design elements are the same.
  • I have tested it in IE Browser.

How was the code tested?

-Locally

What new thing you came across while writing this code?

-The closed‑conversation banner is delayed via MCK_BOT_MESSAGE_DELAY, and showClosedConversationBanner behavior is influenced by KommunicateUI.isConvJustResolved.

In case you fixed a bug then please describe the root cause of it?

-Root cause: the delayed setTimeout that shows the “Restart this conversation” banner wasn’t cancelled on restart, so it could fire later and re‑show the banner, clearing the input.

Screenshot

image

NOTE: Make sure you're comparing your branch with the correct base branch

Summary by CodeRabbit

  • New Features

    • Delayed, debounced display of the "closed conversation" banner that respects tab activity and timing.
  • Bug Fixes

    • Clears pending closed-conversation banners when conversations restart or reopen to avoid stale UI.
    • Prevents duplicate or lingering banners by canceling scheduled banners when conditions change.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 474cad3746

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread webplugin/js/app/kommunicate-ui.js Outdated
Comment on lines +114 to +116
!KommunicateUI.pendingClosedConversationBanner ||
KommunicateUI.closedConversationBannerTabId !== CURRENT_GROUP_DATA.tabId
) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate delayed banner on true active tab id

The timeout callback drops the banner whenever CURRENT_GROUP_DATA.tabId no longer matches the scheduled tab, but that global is reassigned for any incoming KM_STATUS message (see mck-sidebox-1.0.js around the status handler where CURRENT_GROUP_DATA.tabId = resp.message.groupId). In practice, if conversation A is resolved and scheduled, then a status update for conversation B arrives before the delay expires, this check returns early and the resolved banner/input lock never appears for A even if A is still the open chat. This introduces a missed-resolved-state regression under normal multi-conversation socket traffic.

Useful? React with 👍 / 👎.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds tab-aware, debounced closed-conversation banner state and APIs to KommunicateUI, and integrates timeout scheduling/cleanup into sidebox flows so the closed-conversation banner is shown or cancelled based on tab and delay.

Changes

Cohort / File(s) Summary
Kommunicate UI: closed-conversation state & APIs
webplugin/js/app/kommunicate-ui.js
Adds public properties closedConversationBannerTimeoutId, closedConversationBannerTabId, pendingClosedConversationBanner; adds scheduleClosedConversationBanner(delayMs, tabId) and clearClosedConversationBannerTimeout(); updates showClosedConversationBanner() to clear pending timeout when conversation is not closed.
Sidebox: closed-conversation flow integration
webplugin/js/app/mck-sidebox-1.0.js
Replaces direct timeout with KommunicateUI.scheduleClosedConversationBanner(...) for delayed bot messages; calls KommunicateUI.clearClosedConversationBannerTimeout() in restartConversation when tab matches; adjusts CSAT/closed-conversation UI updates and post-feedback flow to asynchronously show banner and refresh scrolling.

Sequence Diagram(s)

sequenceDiagram
    participant Sidebox as Sidebox
    participant Kommunicate as KommunicateUI
    participant Timer as Timeout

    Sidebox->>Kommunicate: scheduleClosedConversationBanner(delayMs, tabId)
    Kommunicate->>Kommunicate: clear existing timeout (if any)
    Kommunicate->>Timer: setTimeout -> after delay
    Note right of Timer: delay elapses
    Timer->>Kommunicate: timeout callback
    Kommunicate->>Kommunicate: if pending && tabId matches -> showClosedConversationBanner(true)
    Kommunicate->>Sidebox: (banner shown) update UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

codex

Suggested reviewers

  • devashishmamgain
  • AashishBhatt5
🚥 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
Title check ✅ Passed The title 'restart conversation' directly corresponds to the main objective of the PR, which is to enable restarting a conversation after it is resolved.
Description check ✅ Passed The PR description covers the main objective, includes testing details, explains the root cause and implementation approach, and provides a relevant screenshot.

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

✨ 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 restart-conversations-issue

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
Copy Markdown
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

🧹 Nitpick comments (1)
webplugin/js/app/kommunicate-ui.js (1)

112-120: Reset pending banner state after timeout fires.

When the delayed path succeeds, internal pending/tab state remains set until another explicit clear. Resetting it in-callback avoids stale state across later UI transitions.

Proposed tweak
         KommunicateUI.closedConversationBannerTimeoutId = setTimeout(function () {
             if (
                 !KommunicateUI.pendingClosedConversationBanner ||
                 KommunicateUI.closedConversationBannerTabId !== CURRENT_GROUP_DATA.tabId
             ) {
                 return;
             }
+            KommunicateUI.clearClosedConversationBannerTimeout();
             KommunicateUI.showClosedConversationBanner(true);
         }, delayMs);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webplugin/js/app/kommunicate-ui.js` around lines 112 - 120, The timeout
callback should clear the pending banner state when it runs successfully to
avoid leaving stale flags; inside the existing setTimeout callback (where it
checks KommunicateUI.pendingClosedConversationBanner and tabId and then calls
KommunicateUI.showClosedConversationBanner(true)), reset
KommunicateUI.pendingClosedConversationBanner to false and clear
KommunicateUI.closedConversationBannerTabId (and clear
KommunicateUI.closedConversationBannerTimeoutId if desired) so the internal
state is cleared after the delayed action completes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@webplugin/js/app/mck-sidebox-1.0.js`:
- Line 4224: The call to KommunicateUI.clearClosedConversationBannerTimeout()
unconditionally clears global timeout state and should only clear if the current
tab owns it; update the restartConversation flow to either add a new
KommunicateUI.clearClosedConversationBannerTimeoutForTab(tabId) or guard the
existing call by checking KommunicateUI.closedConversationBannerTabId ===
CURRENT_GROUP_DATA.tabId before invoking clearClosedConversationBannerTimeout();
reference the symbols restartConversation, clearClosedConversationBannerTimeout,
closedConversationBannerTabId and CURRENT_GROUP_DATA.tabId when applying the
change.

---

Nitpick comments:
In `@webplugin/js/app/kommunicate-ui.js`:
- Around line 112-120: The timeout callback should clear the pending banner
state when it runs successfully to avoid leaving stale flags; inside the
existing setTimeout callback (where it checks
KommunicateUI.pendingClosedConversationBanner and tabId and then calls
KommunicateUI.showClosedConversationBanner(true)), reset
KommunicateUI.pendingClosedConversationBanner to false and clear
KommunicateUI.closedConversationBannerTabId (and clear
KommunicateUI.closedConversationBannerTimeoutId if desired) so the internal
state is cleared after the delayed action completes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: da49c46e-9272-4ed1-9182-0533bdf0744e

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8a495 and 474cad3.

📒 Files selected for processing (2)
  • webplugin/js/app/kommunicate-ui.js
  • webplugin/js/app/mck-sidebox-1.0.js

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
Copy link
Copy Markdown
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.

♻️ Duplicate comments (1)
webplugin/js/app/mck-sidebox-1.0.js (1)

15521-15524: ⚠️ Potential issue | 🟡 Minor

Scope delayed banner timers per tab.

KommunicateUI.scheduleClosedConversationBanner() in webplugin/js/app/kommunicate-ui.js:1-50 clears a singleton closedConversationBannerTimeoutId before every schedule. In a multi-tab session, scheduling here for tab B cancels tab A's still-pending delayed banner, so only the most recent tab keeps its restart CTA timing. Please key the timeout/pending state by tabId instead of sharing one global slot.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webplugin/js/app/mck-sidebox-1.0.js` around lines 15521 - 15524, The
scheduling currently uses a singleton closedConversationBannerTimeoutId that is
cleared on every call to KommunicateUI.scheduleClosedConversationBanner(), which
causes timers from other tabs to be cancelled; change the implementation to
track timeouts per tabId (use a map/object keyed by tabId) so
scheduleClosedConversationBanner(tabId, ...) stores the timeout under that tabId
and clear only that specific entry when rescheduling or cancelling; update any
references that clear or read closedConversationBannerTimeoutId to use the
per-tab map (e.g., use
closedConversationBannerTimeouts[CURRENT_GROUP_DATA.tabId]) and ensure
KommunicateUI.scheduleClosedConversationBanner is invoked with the
CURRENT_GROUP_DATA.tabId when scheduling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@webplugin/js/app/mck-sidebox-1.0.js`:
- Around line 15521-15524: The scheduling currently uses a singleton
closedConversationBannerTimeoutId that is cleared on every call to
KommunicateUI.scheduleClosedConversationBanner(), which causes timers from other
tabs to be cancelled; change the implementation to track timeouts per tabId (use
a map/object keyed by tabId) so scheduleClosedConversationBanner(tabId, ...)
stores the timeout under that tabId and clear only that specific entry when
rescheduling or cancelling; update any references that clear or read
closedConversationBannerTimeoutId to use the per-tab map (e.g., use
closedConversationBannerTimeouts[CURRENT_GROUP_DATA.tabId]) and ensure
KommunicateUI.scheduleClosedConversationBanner is invoked with the
CURRENT_GROUP_DATA.tabId when scheduling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 813af65a-94f4-4841-8040-becc81209191

📥 Commits

Reviewing files that changed from the base of the PR and between 474cad3 and d2f2045.

📒 Files selected for processing (1)
  • webplugin/js/app/mck-sidebox-1.0.js

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
setTimeout(function () {
KommunicateUI.showClosedConversationBanner(true);
}, MCK_BOT_MESSAGE_DELAY);
KommunicateUI.isConvJustResolved = !!!KommunicateUI.isConvJustResolved;
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.

"KommunicateUI.isConvJustResolved = !!!KommunicateUI.isConvJustResolved;

"
this line is present in both if and else condition . if its not dependent on any condition then keep it outside and use it once

Copy link
Copy Markdown
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

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

Inline comments:
In `@webplugin/js/app/mck-sidebox-1.0.js`:
- Around line 15516-15525: The current code toggles
KommunicateUI.isConvJustResolved using the triple-negation pattern; change this
to set the flag deterministically to true (KommunicateUI.isConvJustResolved =
true) when a bot-sent message meets the conditions (MCK_BOT_MESSAGE_DELAY !== 0,
mckMessageLayout.isMessageSentByBot(resp.message, contact), and
!CURRENT_GROUP_DATA.TOKENIZE_RESPONSE) so duplicate resolved events do not flip
it back; keep the existing restart/reset path that clears
KommunicateUI.isConvJustResolved to false elsewhere.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7bc9be05-4977-400c-a067-ce284002ecfe

📥 Commits

Reviewing files that changed from the base of the PR and between d2f2045 and 3806da5.

📒 Files selected for processing (1)
  • webplugin/js/app/mck-sidebox-1.0.js

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
Comment thread webplugin/js/app/kommunicate-ui.js Outdated
Comment thread webplugin/js/app/mck-sidebox-1.0.js
'#km-widget-options',
'.mck-box-form-container'
);
kommunicateCommons.show('.mck-csat-text-1');
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Shows the restart banner text (“If you have any other queries, just Restart this conversation”).

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
});
_this.restartConversation = function (event) {
kmWidgetEvents.eventTracking(eventMapping.onRestartConversationClick);
kommunicateCommons.hide('.mck-csat-text-1');
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So this block is what brings the chat input back when the user clicks “Restart conversation.”

Comment thread webplugin/js/app/mck-sidebox-1.0.js
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