Skip to content

Commit f2d2aff

Browse files
committed
tweaks
1 parent 749826d commit f2d2aff

File tree

14 files changed

+259
-26
lines changed

14 files changed

+259
-26
lines changed

backend/agents/agent.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ async def func(path: str):
120120
1a. Is this a general question, command to build something, etc.?
121121
2. Which files are relevant to the question or would be needed to perform the request?
122122
2a. What page should the user be navigated to to see/verify the change? (e.g. /settings since we are working on that page)
123+
2b. If there's weird behavior, what files should we cat to double check on the contents?
123124
3. What commands might you need to run?
124125
3a. What packages need to be installed?
125126
4. For EACH stack-specific tip, what do you need to keep in mind or how does this adjust your plan?
@@ -199,18 +200,11 @@ async def func(path: str):
199200
{stack_text}
200201
</stack>
201202
202-
<project-files>
203-
{files_text}
204-
</project-files>
205-
206-
<plan>
207-
{plan_text}
208-
</plan>
209-
210203
<tips>
211204
- When you use these code blocks the system will automatically apply the file changes (do not also use tools to do the same thing).
212205
- This apply will happen after you've finished your response and automatically include a git commit of all changes.
213206
- No need to run `npm run dev`, etc since the sandbox will handle that.
207+
- The Spark Stack UI has built in a "Preview" window of the changes to the right as well as a UI for the user to view/export raw files and config deployment/env variables.
214208
</tips>
215209
216210
Follow the <plan>.
@@ -268,6 +262,24 @@ def _parse_follow_ups(content: str) -> List[str]:
268262
return follow_ups
269263

270264

265+
def _append_last_user_message(messages: List[dict], text: str) -> List[dict]:
266+
last_user_message = next(
267+
(m for m in reversed(messages) if m.get("role") == "user"), None
268+
)
269+
if last_user_message:
270+
if isinstance(last_user_message["content"], list):
271+
if last_user_message["content"] and isinstance(
272+
last_user_message["content"][0], dict
273+
):
274+
last_user_message["content"][0]["text"] += "\n\n" + text
275+
else:
276+
last_user_message["content"].append({"type": "text", "text": text})
277+
else:
278+
last_user_message["content"] += "\n\n" + text
279+
else:
280+
raise ValueError("No user message found")
281+
282+
271283
class Agent:
272284
def __init__(self, project: Project, stack: Stack, user: User):
273285
self.project = project
@@ -413,8 +425,6 @@ async def step(
413425
system_prompt = SYSTEM_EXEC_PROMPT.format(
414426
project_text=project_text,
415427
stack_text=stack_text,
416-
files_text=files_text,
417-
plan_text=plan_content,
418428
user_text=user_text,
419429
)
420430

@@ -437,6 +447,11 @@ async def step(
437447
for message in messages
438448
],
439449
]
450+
_append_last_user_message(
451+
exec_messages,
452+
f"---\n<project-files>\n{files_text}\n</project-files>\n<plan>\n{plan_content}\n</plan>\n---",
453+
)
454+
print(exec_messages)
440455
tools = [build_run_command_tool(self.sandbox), build_navigate_to_tool(self)]
441456

442457
model = LLM_PROVIDERS[MAIN_PROVIDER]()

frontend/package-lock.json

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@radix-ui/react-avatar": "^1.1.1",
1414
"@radix-ui/react-dialog": "^1.1.2",
1515
"@radix-ui/react-dropdown-menu": "^2.1.2",
16+
"@radix-ui/react-progress": "^1.1.1",
1617
"@radix-ui/react-scroll-area": "^1.2.1",
1718
"@radix-ui/react-select": "^2.1.2",
1819
"@radix-ui/react-slot": "^1.1.0",

frontend/src/app/chats/components/Chat.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
} from '@/components/ui/tooltip';
4141
import { useToast } from '@/hooks/use-toast';
4242
import { useShareChat } from '@/hooks/use-share-chat';
43+
import { Progress } from '@/components/ui/progress';
4344

4445
const STARTER_PROMPTS = [
4546
'Build a 90s themed cat facts app with catfact.ninja API',
@@ -495,6 +496,37 @@ const statusMap = {
495496
},
496497
};
497498

499+
const LoadingState = () => {
500+
const [progress, setProgress] = useState(0);
501+
502+
useEffect(() => {
503+
const duration = 120000; // 2 minutes in milliseconds
504+
const interval = 100; // Update every 100ms
505+
const increment = (interval / duration) * 100;
506+
507+
const timer = setInterval(() => {
508+
setProgress((prev) => {
509+
const next = prev + increment;
510+
return next >= 100 ? 100 : next;
511+
});
512+
}, interval);
513+
514+
return () => clearInterval(timer);
515+
}, []);
516+
517+
return (
518+
<div className="absolute inset-0 flex flex-col items-center justify-center gap-3">
519+
<Loader2 className="h-8 w-8 animate-spin text-primary" />
520+
<p className="text-sm text-muted-foreground">
521+
Booting up your development environment...
522+
</p>
523+
<div className="w-64">
524+
<Progress value={progress} className="h-2" />
525+
</div>
526+
</div>
527+
);
528+
};
529+
498530
export function Chat({
499531
messages,
500532
onSendMessage,
@@ -701,14 +733,7 @@ export function Chat({
701733
{!showStackPacks &&
702734
messages.length <= 1 &&
703735
['BUILDING', 'OFFLINE', 'BUILDING_WAITING'].includes(status) && (
704-
<>
705-
<div className="absolute inset-0 flex flex-col items-center justify-center gap-3">
706-
<Loader2 className="h-8 w-8 animate-spin text-primary" />
707-
<p className="text-sm text-muted-foreground">
708-
Booting up your development environment...
709-
</p>
710-
</div>
711-
</>
736+
<LoadingState />
712737
)}
713738
{messages.length === 0 && showStackPacks ? (
714739
<EmptyState

frontend/src/app/chats/components/FilesTab.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const FileContent = ({ selectedFile, isLoading, fileContent }) => {
139139
<Editor
140140
height="100%"
141141
defaultLanguage={getLanguageFromFilename(selectedFile)}
142+
language={getLanguageFromFilename(selectedFile)}
142143
value={isLoading ? 'Loading...' : fileContent}
143144
theme="vs-dark"
144145
options={{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import * as ProgressPrimitive from "@radix-ui/react-progress"
5+
6+
import { cn } from "@/lib/utils"
7+
8+
const Progress = React.forwardRef(({ className, value, ...props }, ref) => (
9+
<ProgressPrimitive.Root
10+
ref={ref}
11+
className={cn(
12+
"relative h-2 w-full overflow-hidden rounded-full bg-primary/20",
13+
className
14+
)}
15+
{...props}>
16+
<ProgressPrimitive.Indicator
17+
className="h-full w-full flex-1 bg-primary transition-all"
18+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }} />
19+
</ProgressPrimitive.Root>
20+
))
21+
Progress.displayName = ProgressPrimitive.Root.displayName
22+
23+
export { Progress }

frontend/src/lib/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export function getLanguageFromFilename(filename) {
2424
sh: 'shell',
2525
bash: 'shell',
2626
txt: 'plaintext',
27+
mjs: 'javascript',
28+
json: 'json',
2729
};
2830
return languageMap[extension] || 'plaintext';
2931
}

images/NextjsP5DockerFile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ RUN apt-get update && \
1515

1616
RUN node --version && npm --version
1717

18-
RUN npx --yes create-next-app@latest frontend --js --tailwind --no-eslint --src-dir src --app --no-turbopack --yes && \
18+
RUN npx --yes create-next-app@latest frontend --js --tailwind -src-dir src --app --no-turbopack --yes && \
1919
cd frontend && \
2020
npm run build
2121

22-
RUN curl -o /frontend/public/sketch.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/p5/public/sketch.js && \
22+
RUN curl -o /frontend/next.config.mjs https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/next.config.mjs.example && \
23+
curl -o /frontend/.eslintrc.json https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/.eslintrc.json.example && \
24+
curl -o /frontend/public/sketch.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/p5/public/sketch.js && \
2325
curl -o /frontend/public/helpers.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/p5/public/helpers.js && \
2426
curl -o /frontend/public/objects.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/p5/public/objects.js && \
2527
curl -o /frontend/src/app/globals.css https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/p5/src/app/globals.css && \

images/NextjsPixiDockerFile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ RUN apt-get update && \
1515

1616
RUN node --version && npm --version
1717

18-
RUN npx --yes create-next-app@latest frontend --js --tailwind --no-eslint --src-dir src --app --no-turbopack --yes && \
18+
RUN npx --yes create-next-app@latest frontend --js --tailwind --src-dir src --app --no-turbopack --yes && \
1919
cd frontend && \
2020
npm install pixi.js @pixi/mesh-extras raw-loader --force && \
2121
npm run build
2222

23-
RUN curl -o /frontend/next.config.mjs https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/pixi/next.config.mjs && \
23+
RUN curl -o /frontend/next.config.mjs https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/next.config.mjs.example && \
24+
curl -o /frontend/.eslintrc.json https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/.eslintrc.json.example && \
2425
curl -o /frontend/src/app/layout.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/pixi/src/app/layout.js && \
2526
curl -o /frontend/src/app/page.js https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/pixi/src/app/page.js && \
2627
mkdir -p /frontend/src/app/pixi && \

images/NextjsShadcnDockerFile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ RUN apt-get update && \
1515

1616
RUN node --version && npm --version
1717

18-
RUN npx --yes create-next-app@latest frontend --js --tailwind --no-eslint --src-dir src --app --no-turbopack --yes && \
18+
RUN npx --yes create-next-app@latest frontend --js --tailwind --src-dir src --app --no-turbopack --yes && \
1919
cd frontend && \
2020
npm install lucide-react axios recharts @radix-ui/react-icons tailwind-merge react-hook-form --force && \
2121
(echo "\n\n\n" | npx shadcn@latest init --defaults --force --yes) && \
2222
(echo "\n\n\n" | npx shadcn@latest add --yes --all) && \
2323
npm run build
2424

25-
RUN curl -o /frontend/next.config.mjs https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/next.config.mjs.example
25+
RUN curl -o /frontend/next.config.mjs https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/next.config.mjs.example && \
26+
curl -o /frontend/.eslintrc.json https://raw.githubusercontent.com/sshh12/prompt-stack/refs/heads/main/images/nextjs/.eslintrc.json.example
2627

2728
RUN ls -asl /frontend && \
2829
ls -asl /frontend/public && \

0 commit comments

Comments
 (0)