Skip to content

Commit e3e70db

Browse files
committed
feat: upgrade to react-chatbotify v2.2.0 with compatibility improvements
- Update react-chatbotify to 2.2.0 - Add version announcement for debug builds - Fix double-click issue in controlled component mode - Implement changes from vg branch - Remove planning files and build improvements
1 parent 2bdc12c commit e3e70db

File tree

15 files changed

+175
-103
lines changed

15 files changed

+175
-103
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
- **Community Interest Targeting**: Community involvement question now only shown to users who provide contact information
1717
- **Anonymous Feedback Improvements**: Community interest field hidden from summary for anonymous submissions
1818
- **Focus Management**: Fixed keyboard focus jumping to previous questions; now properly targets current question only
19+
- **Q&A Response System**: Replaced unreliable `streamMessage` with direct API calls using `injectMessage` for consistent response display
1920

2021
### Fixed
22+
- **Critical Q&A Display Issue**: Fixed problem where Q&A responses stopped displaying after 3-4 questions due to react-chatbotify's `streamMessage` accumulating state
23+
- **Query ID Generation**: Implemented UUID-based query ID generation directly in QA flow to ensure proper feedback tracking
24+
- **Response Reliability**: Q&A responses now display consistently regardless of conversation length
2125
- Resolved form state persistence issues where previous session data would interfere with new submissions
2226
- Fixed multiple checkbox selection display in feedback summary (was showing only one selection)
2327
- Corrected timing issues with form context updates using chatState.userInput pattern
2428
- Fixed anonymous feedback showing previous contact information in summary
2529
- Improved keyboard accessibility for checkboxes with proper focus management
30+
- Removed broken fallback loop flow that used deprecated `streamMessage` approach
2631

2732
## [2.0.0-rc.1] - 2025-05-28
2833

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ The bot supports several conversation flows:
5252
- Built-in feedback system with thumbs up/down options after each response
5353
- Automatic feedback tracking and analytics
5454
- Users can provide feedback or continue asking questions immediately
55-
- Negative feedback offers direct path to support ticket creation
5655
- Requires user to be logged in
5756

5857
### 🎫 Support Ticket Flows
@@ -238,7 +237,7 @@ REACT_APP_API_KEY=your-api-key-here
238237
239238
The bot integrates with the ACCESS Q&A API and JSM (Jira Service Management) for ticket creation. Configure your backend endpoints to handle:
240239
241-
- Q&A queries with streaming responses
240+
- Q&A queries with JSON responses
242241
- Support ticket creation with ProForma field mapping
243242
- File upload processing
244243
- User authentication and session management

build/static/js/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/static/js/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 28 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@snf/access-qa-bot",
3-
"version": "2.4.8-debug.0",
3+
"version": "2.6.0-debug.3",
44
"private": false,
55
"homepage": ".",
66
"description": "ACCESS Q&A Bot React Component with support ticket creation, feedback collection, and ProForma integration",
@@ -24,7 +24,7 @@
2424
"@rcb-plugins/html-renderer": "^0.3.1",
2525
"@rcb-plugins/input-validator": "^0.3.0",
2626
"@rcb-plugins/markdown-renderer": "^0.3.1",
27-
"react-chatbotify": "^2.1.0",
27+
"react-chatbotify": "^2.2.0",
2828
"uuid": "^11.1.0"
2929
},
3030
"peerDependencies": {
@@ -45,6 +45,7 @@
4545
"@eslint/js": "^9.31.0",
4646
"@rollup/plugin-babel": "^6.0.4",
4747
"@rollup/plugin-commonjs": "^25.0.7",
48+
"@rollup/plugin-json": "^6.1.0",
4849
"@rollup/plugin-node-resolve": "^15.2.3",
4950
"@rollup/plugin-replace": "^5.0.7",
5051
"@rollup/plugin-terser": "^0.4.4",

publishing.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,24 @@ After the package is published to npm, users can install and use it in their pro
245245
npm install @snf/access-qa-bot
246246
```
247247

248-
For more detailed usage instructions and examples, refer to the README.md file.
248+
For more detailed usage instructions and examples, refer to the README.md file.
249+
250+
## Simple Debug Releases Workflow
251+
252+
For quick debug releases during development:
253+
254+
```bash
255+
# Update version (e.g., 2.6.0-debug.0 to 2.6.0-debug.1)
256+
npm version 2.6.0-debug.1
257+
258+
# Build the library
259+
npm run build:lib
260+
261+
# Publish with debug tag
262+
npm publish --tag debug --access public
263+
```
264+
265+
This workflow is useful for:
266+
- Quick iterations during development
267+
- Testing specific versions in integration environments
268+
- Publishing debug versions without affecting the main release process

rollup.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import terser from '@rollup/plugin-terser';
55
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
66
import postcss from 'rollup-plugin-postcss';
77
import replace from '@rollup/plugin-replace';
8+
import json from '@rollup/plugin-json';
89

910
import { readFileSync } from 'fs';
1011
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
@@ -29,6 +30,7 @@ export default [
2930
],
3031
plugins: [
3132
peerDepsExternal(),
33+
json(),
3234
postcss({
3335
extensions: ['.css'],
3436
minimize: true,
@@ -63,6 +65,7 @@ export default [
6365
globals: {}
6466
},
6567
plugins: [
68+
json(),
6669
postcss({
6770
extensions: ['.css'],
6871
minimize: true,

src/components/BotController.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,24 @@ const BotController = React.forwardRef(({
2323
const messages = useMessages();
2424
const chatWindow = useChatWindow();
2525

26-
const lastOpenRef = useRef(currentOpen);
26+
const lastOpenRef = useRef(null); // Start with null to detect initial state
2727
const fromEventRef = useRef(false);
2828

2929
useLoginStateTransition(isBotLoggedIn);
3030

3131
// Sync open state with chat window when it changes (but not when change came from event)
3232
useEffect(() => {
3333
if (!embedded && chatWindow && chatWindow.toggleChatWindow) {
34+
// Handle initial state and subsequent changes
3435
if (lastOpenRef.current !== currentOpen && !fromEventRef.current) {
35-
if (chatWindow && chatWindow.toggleChatWindow) {
36-
chatWindow.toggleChatWindow(currentOpen);
37-
lastOpenRef.current = currentOpen;
38-
}
36+
37+
// Use a small delay to ensure chatWindow is fully initialized
38+
setTimeout(() => {
39+
if (chatWindow && chatWindow.toggleChatWindow) {
40+
chatWindow.toggleChatWindow(currentOpen);
41+
}
42+
}, 0);
43+
lastOpenRef.current = currentOpen;
3944
}
4045
fromEventRef.current = false;
4146
}

src/components/QABot.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ import { v4 as uuidv4 } from 'uuid';
77
import BotController from './BotController';
88
import useThemeColors from '../hooks/useThemeColors';
99
import useChatBotSettings from '../hooks/useChatBotSettings';
10-
import useHandleAIQuery from '../hooks/useHandleAIQuery';
1110
import useUpdateHeader from '../hooks/useUpdateHeader';
1211
import useRingEffect from '../hooks/useRingEffect';
1312
import useFocusableSendButton from '../hooks/useFocusableSendButton';
1413
import useKeyboardNavigation from '../hooks/useKeyboardNavigation';
1514
import { DEFAULT_CONFIG, buildWelcomeMessage } from '../config/constants';
1615
import { createBotFlow } from '../utils/create-bot-flow';
1716
import { FormProvider, useFormContext } from '../contexts/FormContext';
18-
17+
import packageJson from '../../package.json';
18+
19+
// Build signature for deployment verification (only if debug enabled)
20+
if (localStorage.getItem('QaBotDebug') === 'true') {
21+
// eslint-disable-next-line no-console
22+
console.info(
23+
`%c🤖 ACCESS QA Bot | v${packageJson.version} | react-chatbotify v2.2.0 [${new Date().toISOString().slice(0,10)}]`,
24+
'background: #107180; color: white; padding: 8px; border-radius: 3px; font-weight: bold;'
25+
);
26+
}
1927

2028
const generateSessionId = () => {
2129
return `qa_bot_session_${uuidv4()}`;
@@ -55,12 +63,11 @@ const QABotInternal = React.forwardRef((props, botRef) => {
5563
accessId
5664
} = props;
5765

58-
const finalApiKey = apiKey || ((typeof process !== 'undefined' && process.env) ? process.env.REACT_APP_API_KEY : null);
66+
const finalApiKey = apiKey || process.env.REACT_APP_API_KEY || null;
5967

6068
const [isBotLoggedIn, setIsBotLoggedIn] = useState(isLoggedIn !== undefined ? isLoggedIn : false);
6169
const sessionIdRef = useRef(getOrCreateSessionId());
6270
const sessionId = sessionIdRef.current;
63-
const [currentQueryId, setCurrentQueryId] = useState(null);
6471

6572
// Use Form Context instead of local state
6673
const { ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, resetTicketForm, resetFeedbackForm } = useFormContext();
@@ -72,9 +79,6 @@ const QABotInternal = React.forwardRef((props, botRef) => {
7279
}
7380
}, [isLoggedIn]);
7481

75-
// Initialize currentQueryId as null - will be set by useHandleAIQuery
76-
// when actual queries are processed
77-
7882
// Listen for chat window toggle events from react-chatbotify
7983
useEffect(() => {
8084
if (!embedded && onOpenChange) {
@@ -83,6 +87,7 @@ const QABotInternal = React.forwardRef((props, botRef) => {
8387
botRef.current._markAsUserInteraction();
8488
}
8589
const newOpenState = event.data.newState;
90+
8691
onOpenChange(newOpenState);
8792
};
8893
window.addEventListener('rcb-toggle-chat-window', handleChatWindowToggle);
@@ -100,13 +105,11 @@ const QABotInternal = React.forwardRef((props, botRef) => {
100105
const chatBotSettings = useChatBotSettings({
101106
themeColors,
102107
embedded,
103-
defaultOpen: open,
108+
defaultOpen: false, // Always start closed for floating mode, controlled via BotController
104109
isLoggedIn: isBotLoggedIn,
105110
loginUrl
106111
});
107112

108-
const handleQuery = useHandleAIQuery(finalApiKey, sessionId, setCurrentQueryId);
109-
110113
const formContext = useMemo(() => ({
111114
ticketForm: ticketForm || {},
112115
feedbackForm: feedbackForm || {},
@@ -116,13 +119,14 @@ const QABotInternal = React.forwardRef((props, botRef) => {
116119
resetFeedbackForm
117120
}), [ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, resetTicketForm, resetFeedbackForm]);
118121

122+
// loads plugins to be passed into chatbot, matching pattern in docs
123+
const plugins = [HtmlRenderer(), MarkdownRenderer(), InputValidator()];
124+
119125
const flow = useMemo(() => createBotFlow({
120126
welcomeMessage,
121127
isBotLoggedIn,
122128
loginUrl,
123-
handleQuery,
124129
sessionId,
125-
currentQueryId,
126130
ticketForm,
127131
setTicketForm: updateTicketForm,
128132
feedbackForm,
@@ -134,7 +138,7 @@ const QABotInternal = React.forwardRef((props, botRef) => {
134138
name: userName || null,
135139
accessId: accessId || null
136140
}
137-
}), [welcomeMessage, isBotLoggedIn, loginUrl, handleQuery, sessionId, currentQueryId, ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, formContext, finalApiKey, userEmail, userName, accessId]);
141+
}), [welcomeMessage, isBotLoggedIn, loginUrl, sessionId, ticketForm, feedbackForm, updateTicketForm, updateFeedbackForm, formContext, finalApiKey, userEmail, userName, accessId]);
138142

139143
useUpdateHeader(isBotLoggedIn, containerRef);
140144
useRingEffect(ringEffect, containerRef);
@@ -177,7 +181,7 @@ const QABotInternal = React.forwardRef((props, botRef) => {
177181
key={`chatbot-${sessionId}-${isBotLoggedIn}`}
178182
settings={chatBotSettings}
179183
flow={flow}
180-
plugins={[HtmlRenderer(), MarkdownRenderer(), InputValidator()]}
184+
plugins={plugins}
181185
/>
182186
{/* Live region for screen reader announcements */}
183187
<div

0 commit comments

Comments
 (0)