Skip to content

Commit eb2cf89

Browse files
feat: Add Upgrade Audit Tool and AI ChatInput POC for GSoC 2026 roadmap
1 parent 3f8a554 commit eb2cf89

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

packages/react/src/views/ChatInput/ChatInput.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import useShowCommands from '../../hooks/useShowCommands';
3434
import useSearchMentionUser from '../../hooks/useSearchMentionUser';
3535
import formatSelection from '../../lib/formatSelection';
3636
import { parseEmoji } from '../../lib/emoji';
37+
import { GeminiAiAdapter } from '../../lib/ai/GeminiAiAdapter';
3738

3839
const ChatInput = ({ scrollToBottom, clearUnreadDividerRef }) => {
3940
const { styleOverrides, classNames } = useComponentOverrides('ChatInput');
@@ -57,6 +58,24 @@ const ChatInput = ({ scrollToBottom, clearUnreadDividerRef }) => {
5758
const [showCommandList, setShowCommandList] = useState(false);
5859
const [filteredCommands, setFilteredCommands] = useState([]);
5960
const [isMsgLong, setIsMsgLong] = useState(false);
61+
const [isAiLoading, setIsAiLoading] = useState(false);
62+
63+
const handleAiAssist = async () => {
64+
setIsAiLoading(true);
65+
try {
66+
const adapter = new GeminiAiAdapter('dummy-key');
67+
const dummyContext = [{ msg: messageRef.current.value || 'Hello! What can I help you with today?' }];
68+
const replies = await adapter.getSmartReplies(dummyContext);
69+
if (replies && replies.length > 0) {
70+
messageRef.current.value = (messageRef.current.value + ' ' + replies[0]).trim();
71+
setDisableButton(false);
72+
}
73+
} catch (e) {
74+
console.error(e);
75+
dispatchToastMessage({ type: 'error', message: 'AI generation failed.' });
76+
}
77+
setIsAiLoading(false);
78+
};
6079

6180
const {
6281
isUserAuthenticated,
@@ -635,8 +654,21 @@ const ChatInput = ({ scrollToBottom, clearUnreadDividerRef }) => {
635654
<Box
636655
css={css`
637656
padding: 0.25rem;
657+
display: flex;
658+
gap: 0.5rem;
638659
`}
639660
>
661+
{!isChannelArchived && (
662+
<Button
663+
onClick={handleAiAssist}
664+
type="secondary"
665+
size="small"
666+
disabled={isAiLoading || disableButton === false && messageRef.current?.value?.length > 50}
667+
css={css`border-radius: 4px; border: 1px solid #ddd; background: #f0f0f0;`}
668+
>
669+
{isAiLoading ? '...' : '✨ AI'}
670+
</Button>
671+
)}
640672
{isUserAuthenticated ? (
641673
!isChannelArchived ? (
642674
<ActionButton

scripts/upgrade-audit.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* POC: GSoC 2026 - Stack Modernization & API Audit Tool
3+
* This script demonstrates the automated assessment mechanism for upgrading
4+
* EmbeddedChat to modern versions (Node 20, React 18, latest Rocket.Chat APIs).
5+
*/
6+
7+
const fs = require('fs');
8+
const path = require('path');
9+
10+
const rootDir = process.cwd();
11+
const packagePath = path.join(rootDir, 'package.json');
12+
const reactPkgPath = path.join(rootDir, 'packages/react/package.json');
13+
14+
console.log('--- EmbeddedChat 2026: Upgrade & API Audit POC ---\n');
15+
16+
function auditPackageJson(filePath, label) {
17+
if (!fs.existsSync(filePath)) {
18+
console.error(`[Error] ${label} package.json not found.`);
19+
return;
20+
}
21+
const pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'));
22+
console.log(`[Audit] Scanning ${label}...`);
23+
console.log(` - Name: ${pkg.name}`);
24+
console.log(` - Current Version: ${pkg.version}`);
25+
26+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
27+
const criticalUpdates = [
28+
{ name: 'react', target: '^18.3.0', reason: 'Modernization requirement' },
29+
{ name: 'node', target: '>=20.0.0', reason: 'LTS requirement' },
30+
{ name: '@rocket.chat/sdk', target: '^1.0.0', reason: 'API Unified schema support' },
31+
{ name: 'eslint', target: '^8.0.0', reason: 'Compatibility with React 18 plugins' }
32+
];
33+
34+
criticalUpdates.forEach(update => {
35+
const current = deps[update.name] || 'Not found';
36+
const status = (current === update.target) ? 'OK' : 'NEEDS UPGRADE';
37+
console.log(` - ${update.name.padEnd(16)}: ${current.padEnd(10)} -> Target: ${update.target.padEnd(10)} [${status}]`);
38+
});
39+
}
40+
41+
function scanForDeprecatedPatterns(dir) {
42+
const patterns = [
43+
{ regex: /ReactDOM\.render/g, name: 'ReactDOM.render', fix: 'createRoot (React 18)' },
44+
{ regex: /componentWillReceiveProps/g, name: 'Legacy Lifecycle', fix: 'getDerivedStateFromProps' },
45+
{ regex: /stream-room-messages/g, name: 'Legacy WS Subscription', fix: 'Realtime API v2' }
46+
];
47+
48+
console.log('\n[Code Audit] Scanning for deprecated patterns in src/ ...');
49+
50+
const files = getAllFiles(dir).filter(f => f.endsWith('.js') || f.endsWith('.jsx'));
51+
const findings = [];
52+
53+
files.forEach(file => {
54+
const content = fs.readFileSync(file, 'utf8');
55+
patterns.forEach(p => {
56+
if (p.regex.test(content)) {
57+
findings.push(`[${p.name}] found in ${path.relative(rootDir, file)}. Suggested fix: ${p.fix}`);
58+
}
59+
});
60+
});
61+
62+
if (findings.length > 0) {
63+
findings.slice(0, 5).forEach(f => console.log(` ! ${f}`));
64+
if (findings.length > 5) console.log(` ... and ${findings.length - 5} more findings.`);
65+
} else {
66+
console.log(' - No deprecated patterns found in the sampled files.');
67+
}
68+
}
69+
70+
function getAllFiles(dirPath, arrayOfFiles) {
71+
const files = fs.readdirSync(dirPath);
72+
arrayOfFiles = arrayOfFiles || [];
73+
files.forEach(function(file) {
74+
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
75+
if (file !== 'node_modules' && file !== 'dist') {
76+
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
77+
}
78+
} else {
79+
arrayOfFiles.push(path.join(dirPath, "/", file));
80+
}
81+
});
82+
return arrayOfFiles;
83+
}
84+
85+
auditPackageJson(packagePath, 'Root Monorepo');
86+
auditPackageJson(reactPkgPath, 'React Package');
87+
scanForDeprecatedPatterns(path.join(rootDir, 'packages/react/src'));
88+
89+
console.log('\n[Conclusion] Automated audit complete. Summary generated for GSoC 2026 Roadmap.');

0 commit comments

Comments
 (0)