final updates

This commit is contained in:
Developers Digest
2025-08-08 10:25:18 -04:00
parent da30371d48
commit 6081a9f50a
4 changed files with 29 additions and 58 deletions
+11 -51
View File
@@ -1474,16 +1474,7 @@ It's better to have 3 complete files than 10 incomplete files.`
// Validate generated code for truncation issues
const truncationWarnings: string[] = [];
// Check for common truncation patterns - be more selective about ellipsis
const ellipsisCount = (generatedCode.match(/\.\.\./g) || []).length;
const spreadCount = (generatedCode.match(/\.\.\.[\w]+/g) || []).length;
const suspiciousEllipsis = ellipsisCount > spreadCount &&
generatedCode.includes('...') &&
!generatedCode.includes('Loading...');
if (suspiciousEllipsis) {
truncationWarnings.push('Code contains suspicious "..." patterns that may indicate truncation');
}
// Skip ellipsis checking entirely - too many false positives with spread operators, loading text, etc.
// Check for unclosed file tags
const fileOpenCount = (generatedCode.match(/<file path="/g) || []).length;
@@ -1499,57 +1490,26 @@ It's better to have 3 complete files than 10 incomplete files.`
const filePath = truncationMatch[1];
const content = truncationMatch[2];
// Check for obviously truncated content
if (content.includes('</h') && !content.includes('</html>') &&
!content.includes('</h1>') && !content.includes('</h2>') &&
!content.includes('</h3>') && !content.includes('</h4>') &&
!content.includes('</h5>') && !content.includes('</h6>')) {
// Only check for really obvious HTML truncation - file ends with opening tag
if (content.trim().endsWith('<') || content.trim().endsWith('</')) {
truncationWarnings.push(`File ${filePath} appears to have incomplete HTML tags`);
}
// Check for components that end with "..." in text
if (content.trim().endsWith('...') || content.includes('>...</')) {
truncationWarnings.push(`File ${filePath} may be truncated (ends with ...)`);
}
// Skip "..." check - too many false positives with loading text, etc.
// Check for incomplete React components - only for JS/TS files
// Only check for SEVERE truncation issues
if (filePath.match(/\.(jsx?|tsx?)$/)) {
const hasExport = content.includes('export') || content.includes('module.exports');
const hasReturn = content.includes('return');
const hasClosingBrace = content.trim().endsWith('}') || content.trim().endsWith(';') || content.trim().endsWith('>');
// Only flag missing export for component files, not main.jsx or index files
if (!hasExport && content.length > 100 && !filePath.includes('main.') && !filePath.includes('index.')) {
truncationWarnings.push(`File ${filePath} missing export statement`);
}
// Check for functions without return only if it's a component function
if (content.includes('function') && !hasReturn && !content.includes('=>') &&
content.includes('(') && content.includes(')') && content.length > 100) {
// Only flag if it looks like a React component (has JSX)
if (content.includes('<') && content.includes('>')) {
truncationWarnings.push(`File ${filePath} has function without return statement`);
}
}
// Only flag abrupt ending if file is really short or clearly incomplete
if (!hasClosingBrace && content.length < 50 && content.trim() !== '') {
truncationWarnings.push(`File ${filePath} appears to end abruptly`);
}
// Check for unmatched brackets - with a tolerance for template literals
// Only check for severely unmatched brackets (more than 3 difference)
const openBraces = (content.match(/{/g) || []).length;
const closeBraces = (content.match(/}/g) || []).length;
const braceDiff = Math.abs(openBraces - closeBraces);
if (braceDiff > 1) { // Allow small differences due to template literals
truncationWarnings.push(`File ${filePath} has unmatched braces (${openBraces} open, ${closeBraces} closed)`);
if (braceDiff > 3) { // Only flag severe mismatches
truncationWarnings.push(`File ${filePath} has severely unmatched braces (${openBraces} open, ${closeBraces} closed)`);
}
const openParens = (content.match(/\(/g) || []).length;
const closeParens = (content.match(/\)/g) || []).length;
const parenDiff = Math.abs(openParens - closeParens);
if (parenDiff > 2) { // Allow small differences
truncationWarnings.push(`File ${filePath} has unmatched parentheses`);
// Check if file is extremely short and looks incomplete
if (content.length < 20 && content.includes('function') && !content.includes('}')) {
truncationWarnings.push(`File ${filePath} appears severely truncated`);
}
}
}
+3 -3
View File
@@ -183,10 +183,10 @@ except Exception as e:
// Install only packages that aren't already installed
const packageList = packagesToInstall.join(' ');
// Only send the npm install command message if we're actually installing new packages
await sendProgress({
type: 'command',
command: `npm install ${packageList}`,
message: `Installing ${packagesToInstall.length} new package(s)...`
type: 'info',
message: `Installing ${packagesToInstall.length} new package(s): ${packagesToInstall.join(', ')}`
});
const installResult = await sandboxInstance.runCode(`
+13 -2
View File
@@ -298,7 +298,10 @@ export default function AISandboxPage() {
switch (data.type) {
case 'command':
// Don't show npm install commands - they're handled by info messages
if (!data.command.includes('npm install')) {
addChatMessage(data.command, 'command', { commandType: 'input' });
}
break;
case 'output':
addChatMessage(data.message, 'command', { commandType: 'output' });
@@ -529,7 +532,8 @@ Tip: I automatically detect and install npm packages from your code imports (lik
break;
case 'command':
if (data.command) {
// Don't show npm install commands - they're handled by info messages
if (data.command && !data.command.includes('npm install')) {
addChatMessage(data.command, 'command', { commandType: 'input' });
}
break;
@@ -585,6 +589,13 @@ Tip: I automatically detect and install npm packages from your code imports (lik
case 'warning':
addChatMessage(`${data.message}`, 'system');
break;
case 'info':
// Show info messages, especially for package installation
if (data.message) {
addChatMessage(data.message, 'system');
}
break;
}
} catch (e) {
// Ignore parse errors
@@ -3270,7 +3281,7 @@ Focus on the key sections and content, making it clean and modern.`;
{/* Right Panel - Preview or Generation (2/3 of remaining width) */}
<div className="flex-1 flex flex-col overflow-hidden">
<div className="p-2 bg-card border-b border-border flex justify-between items-center">
<div className="px-4 py-2 bg-card border-b border-border flex justify-between items-center">
<div className="flex items-center gap-4">
<div className="flex bg-[#36322F] rounded-lg p-1">
<button
+1 -1
View File
@@ -67,7 +67,7 @@ export const appConfig = {
packageInstallRefreshDelay: 5000,
// Enable/disable automatic truncation recovery
enableTruncationRecovery: true,
enableTruncationRecovery: false, // Disabled - too many false positives
// Maximum number of truncation recovery attempts per file
maxTruncationRecoveryAttempts: 1,