Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with alternate message when importing from folder and git #1216

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/components/git/GitUrlImport.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
const messages = [filesMessage];

if (commandsMessage) {
messages.push({
role: 'user',
id: generateId(),
content: 'Setup the codebase and Start the application',
});
messages.push(commandsMessage);
}

Expand Down
7 changes: 6 additions & 1 deletion app/utils/folderImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const createChatFromFolder = async (
role: 'assistant',
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}

<boltArtifact id="imported-files" title="Imported Files">
<boltArtifact id="imported-files" title="Imported Files" type="bundled" >
${fileArtifacts
.map(
(file) => `<boltAction type="file" filePath="${file.path}">
Expand All @@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
const messages = [userMessage, filesMessage];

if (commandsMessage) {
messages.push({
role: 'user',
id: generateId(),
content: 'Setup the codebase and Start the application',
});
messages.push(commandsMessage);
}

Expand Down
27 changes: 20 additions & 7 deletions app/utils/projectCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { generateId } from './fileUtils';

export interface ProjectCommands {
type: string;
setupCommand: string;
setupCommand?: string;
startCommand?: string;
followupMessage: string;
}

Expand Down Expand Up @@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
if (availableCommand) {
return {
type: 'Node.js',
setupCommand: `npm install && npm run ${availableCommand}`,
setupCommand: `npm install`,
startCommand: `npm run ${availableCommand}`,
followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
};
}
Expand All @@ -53,7 +55,7 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
if (hasFile('index.html')) {
return {
type: 'Static',
setupCommand: 'npx --yes serve',
startCommand: 'npx --yes serve',
followupMessage: '',
};
}
Expand All @@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
}

export function createCommandsMessage(commands: ProjectCommands): Message | null {
if (!commands.setupCommand) {
if (!commands.setupCommand && !commands.startCommand) {
return null;
}

let commandString = '';

if (commands.setupCommand) {
commandString += `
<boltAction type="shell">${commands.setupCommand}</boltAction>`;
}

if (commands.startCommand) {
commandString += `
<boltAction type="start">${commands.startCommand}</boltAction>
`;
}

return {
role: 'assistant',
content: `
<boltArtifact id="project-setup" title="Project Setup">
<boltAction type="shell">
${commands.setupCommand}
</boltAction>
${commandString}
</boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
id: generateId(),
createdAt: new Date(),
Expand Down