codacus commited on
Commit
f5fbf42
·
unverified ·
1 Parent(s): 7016111

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

Browse files
app/components/git/GitUrlImport.client.tsx CHANGED
@@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
91
  const messages = [filesMessage];
92
 
93
  if (commandsMessage) {
 
 
 
 
 
94
  messages.push(commandsMessage);
95
  }
96
 
 
91
  const messages = [filesMessage];
92
 
93
  if (commandsMessage) {
94
+ messages.push({
95
+ role: 'user',
96
+ id: generateId(),
97
+ content: 'Setup the codebase and Start the application',
98
+ });
99
  messages.push(commandsMessage);
100
  }
101
 
app/utils/folderImport.ts CHANGED
@@ -38,7 +38,7 @@ export const createChatFromFolder = async (
38
  role: 'assistant',
39
  content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
40
 
41
- <boltArtifact id="imported-files" title="Imported Files">
42
  ${fileArtifacts
43
  .map(
44
  (file) => `<boltAction type="file" filePath="${file.path}">
@@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
61
  const messages = [userMessage, filesMessage];
62
 
63
  if (commandsMessage) {
 
 
 
 
 
64
  messages.push(commandsMessage);
65
  }
66
 
 
38
  role: 'assistant',
39
  content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
40
 
41
+ <boltArtifact id="imported-files" title="Imported Files" type="bundled" >
42
  ${fileArtifacts
43
  .map(
44
  (file) => `<boltAction type="file" filePath="${file.path}">
 
61
  const messages = [userMessage, filesMessage];
62
 
63
  if (commandsMessage) {
64
+ messages.push({
65
+ role: 'user',
66
+ id: generateId(),
67
+ content: 'Setup the codebase and Start the application',
68
+ });
69
  messages.push(commandsMessage);
70
  }
71
 
app/utils/projectCommands.ts CHANGED
@@ -3,7 +3,8 @@ import { generateId } from './fileUtils';
3
 
4
  export interface ProjectCommands {
5
  type: string;
6
- setupCommand: string;
 
7
  followupMessage: string;
8
  }
9
 
@@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
33
  if (availableCommand) {
34
  return {
35
  type: 'Node.js',
36
- setupCommand: `npm install && npm run ${availableCommand}`,
 
37
  followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
38
  };
39
  }
@@ -53,7 +55,7 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
53
  if (hasFile('index.html')) {
54
  return {
55
  type: 'Static',
56
- setupCommand: 'npx --yes serve',
57
  followupMessage: '',
58
  };
59
  }
@@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
62
  }
63
 
64
  export function createCommandsMessage(commands: ProjectCommands): Message | null {
65
- if (!commands.setupCommand) {
66
  return null;
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  return {
70
  role: 'assistant',
71
  content: `
72
  <boltArtifact id="project-setup" title="Project Setup">
73
- <boltAction type="shell">
74
- ${commands.setupCommand}
75
- </boltAction>
76
  </boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
77
  id: generateId(),
78
  createdAt: new Date(),
 
3
 
4
  export interface ProjectCommands {
5
  type: string;
6
+ setupCommand?: string;
7
+ startCommand?: string;
8
  followupMessage: string;
9
  }
10
 
 
34
  if (availableCommand) {
35
  return {
36
  type: 'Node.js',
37
+ setupCommand: `npm install`,
38
+ startCommand: `npm run ${availableCommand}`,
39
  followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
40
  };
41
  }
 
55
  if (hasFile('index.html')) {
56
  return {
57
  type: 'Static',
58
+ startCommand: 'npx --yes serve',
59
  followupMessage: '',
60
  };
61
  }
 
64
  }
65
 
66
  export function createCommandsMessage(commands: ProjectCommands): Message | null {
67
+ if (!commands.setupCommand && !commands.startCommand) {
68
  return null;
69
  }
70
 
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
+
84
  return {
85
  role: 'assistant',
86
  content: `
87
  <boltArtifact id="project-setup" title="Project Setup">
88
+ ${commandString}
 
 
89
  </boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
90
  id: generateId(),
91
  createdAt: new Date(),