Skip to content

Commit f5fbf42

Browse files
authored
fix: issue with alternate message when importing from folder and git (#1216)
1 parent 7016111 commit f5fbf42

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

app/components/git/GitUrlImport.client.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
9191
const messages = [filesMessage];
9292

9393
if (commandsMessage) {
94+
messages.push({
95+
role: 'user',
96+
id: generateId(),
97+
content: 'Setup the codebase and Start the application',
98+
});
9499
messages.push(commandsMessage);
95100
}
96101

app/utils/folderImport.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const createChatFromFolder = async (
3838
role: 'assistant',
3939
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
4040
41-
<boltArtifact id="imported-files" title="Imported Files">
41+
<boltArtifact id="imported-files" title="Imported Files" type="bundled" >
4242
${fileArtifacts
4343
.map(
4444
(file) => `<boltAction type="file" filePath="${file.path}">
@@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
6161
const messages = [userMessage, filesMessage];
6262

6363
if (commandsMessage) {
64+
messages.push({
65+
role: 'user',
66+
id: generateId(),
67+
content: 'Setup the codebase and Start the application',
68+
});
6469
messages.push(commandsMessage);
6570
}
6671

app/utils/projectCommands.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { generateId } from './fileUtils';
33

44
export interface ProjectCommands {
55
type: string;
6-
setupCommand: string;
6+
setupCommand?: string;
7+
startCommand?: string;
78
followupMessage: string;
89
}
910

@@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
3334
if (availableCommand) {
3435
return {
3536
type: 'Node.js',
36-
setupCommand: `npm install && npm run ${availableCommand}`,
37+
setupCommand: `npm install`,
38+
startCommand: `npm run ${availableCommand}`,
3739
followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
3840
};
3941
}
@@ -53,7 +55,7 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
5355
if (hasFile('index.html')) {
5456
return {
5557
type: 'Static',
56-
setupCommand: 'npx --yes serve',
58+
startCommand: 'npx --yes serve',
5759
followupMessage: '',
5860
};
5961
}
@@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
6264
}
6365

6466
export function createCommandsMessage(commands: ProjectCommands): Message | null {
65-
if (!commands.setupCommand) {
67+
if (!commands.setupCommand && !commands.startCommand) {
6668
return null;
6769
}
6870

71+
let commandString = '';
72+
73+
if (commands.setupCommand) {
74+
commandString += `
75+
<boltAction type="shell">${commands.setupCommand}</boltAction>`;
76+
}
77+
78+
if (commands.startCommand) {
79+
commandString += `
80+
<boltAction type="start">${commands.startCommand}</boltAction>
81+
`;
82+
}
83+
6984
return {
7085
role: 'assistant',
7186
content: `
7287
<boltArtifact id="project-setup" title="Project Setup">
73-
<boltAction type="shell">
74-
${commands.setupCommand}
75-
</boltAction>
88+
${commandString}
7689
</boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
7790
id: generateId(),
7891
createdAt: new Date(),

0 commit comments

Comments
 (0)