Spaces:
Running
Running
Commit ·
e323945
1
Parent(s): 360c0c8
commit initial 09-12-2025 011
Browse files- src/App.css +23 -0
- src/App.js +67 -39
src/App.css
CHANGED
|
@@ -522,4 +522,27 @@
|
|
| 522 |
@keyframes fadeIn {
|
| 523 |
from { opacity: 0; transform: translateY(5px); }
|
| 524 |
to { opacity: 1; transform: translateY(0); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
}
|
|
|
|
| 522 |
@keyframes fadeIn {
|
| 523 |
from { opacity: 0; transform: translateY(5px); }
|
| 524 |
to { opacity: 1; transform: translateY(0); }
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
.ide-agent-textarea {
|
| 528 |
+
width: 100%;
|
| 529 |
+
height: 70px;
|
| 530 |
+
margin-top: 6px;
|
| 531 |
+
padding: 6px;
|
| 532 |
+
background: #111;
|
| 533 |
+
border: 1px solid #444;
|
| 534 |
+
color: #fff;
|
| 535 |
+
font-family: Consolas, monospace;
|
| 536 |
+
resize: vertical;
|
| 537 |
+
border-radius: 4px;
|
| 538 |
+
}
|
| 539 |
+
.ide-explain {
|
| 540 |
+
margin-top: 6px;
|
| 541 |
+
padding: 6px;
|
| 542 |
+
background: #222;
|
| 543 |
+
border: 1px solid #444;
|
| 544 |
+
color: #fff;
|
| 545 |
+
border-radius: 4px;
|
| 546 |
+
max-height: 120px;
|
| 547 |
+
overflow-y: auto;
|
| 548 |
}
|
src/App.js
CHANGED
|
@@ -102,21 +102,38 @@ function App() {
|
|
| 102 |
|
| 103 |
// =================== AI ===================
|
| 104 |
const handleAskFix = async () => {
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
const handleExplainSelection = async () => {
|
| 112 |
-
const editor = editorRef.current;
|
| 113 |
-
const selected = editor.getModel().getValueInRange(editor.getSelection());
|
| 114 |
-
const code = selected.trim() || currentFile.content;
|
| 115 |
-
const reply = await askAgent(
|
| 116 |
-
`Explain this ${langMeta.id} code:\n${code}`
|
| 117 |
-
);
|
| 118 |
-
setExplanation(reply);
|
| 119 |
-
};
|
| 120 |
|
| 121 |
const updateActiveFileContent = (value) => {
|
| 122 |
const updated = updateFileContent(tree, activePath, value);
|
|
@@ -208,31 +225,42 @@ function App() {
|
|
| 208 |
)}
|
| 209 |
|
| 210 |
{/* Bottom Panels */}
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
{/* ==== SEARCH PANEL ==== */}
|
| 238 |
{searchOpen && (
|
|
|
|
| 102 |
|
| 103 |
// =================== AI ===================
|
| 104 |
const handleAskFix = async () => {
|
| 105 |
+
const userHint = prompt.trim() ? `User request: ${prompt}` : "";
|
| 106 |
+
const reply = await askAgent(
|
| 107 |
+
`Improve, debug, or refactor this ${langMeta.id} file.
|
| 108 |
+
${userHint}
|
| 109 |
+
Return ONLY updated code, no explanation.
|
| 110 |
+
|
| 111 |
+
CODE:
|
| 112 |
+
${currentFile.content}`
|
| 113 |
+
);
|
| 114 |
+
updateActiveFileContent(reply);
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
const handleExplainSelection = async () => {
|
| 119 |
+
const editor = editorRef.current;
|
| 120 |
+
const selected = editor.getModel().getValueInRange(editor.getSelection());
|
| 121 |
+
const code = selected.trim() || currentFile.content;
|
| 122 |
+
|
| 123 |
+
const userHint = prompt.trim()
|
| 124 |
+
? `Focus on: ${prompt}`
|
| 125 |
+
: "Give a clear and simple explanation.";
|
| 126 |
+
|
| 127 |
+
const reply = await askAgent(
|
| 128 |
+
`Explain what this ${langMeta.id} code does, any risks, and improvements.
|
| 129 |
+
${userHint}
|
| 130 |
+
|
| 131 |
+
CODE:
|
| 132 |
+
${code}`
|
| 133 |
+
);
|
| 134 |
+
setExplanation(reply);
|
| 135 |
+
};
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
const updateActiveFileContent = (value) => {
|
| 139 |
const updated = updateFileContent(tree, activePath, value);
|
|
|
|
| 225 |
)}
|
| 226 |
|
| 227 |
{/* Bottom Panels */}
|
| 228 |
+
<div className="ide-panels">
|
| 229 |
+
|
| 230 |
+
{/* OUTPUT WINDOW */}
|
| 231 |
+
<pre className="ide-output">{output}</pre>
|
| 232 |
+
|
| 233 |
+
{/* STDIN INPUT */}
|
| 234 |
+
<input
|
| 235 |
+
className="ide-input-box"
|
| 236 |
+
placeholder="Program input..."
|
| 237 |
+
value={stdin}
|
| 238 |
+
onChange={(e) => setStdin(e.target.value)}
|
| 239 |
+
/>
|
| 240 |
+
|
| 241 |
+
{/* NEW AI PROMPT INPUT */}
|
| 242 |
+
<textarea
|
| 243 |
+
className="ide-agent-textarea"
|
| 244 |
+
placeholder="Ask the AI (e.g., 'optimize', 'add docstring', 'convert to JS'...)"
|
| 245 |
+
value={prompt}
|
| 246 |
+
onChange={(e) => setPrompt(e.target.value)}
|
| 247 |
+
/>
|
| 248 |
+
|
| 249 |
+
{/* EXPLANATION PANEL */}
|
| 250 |
+
{explanation && (
|
| 251 |
+
<div className="ide-explain">{explanation}</div>
|
| 252 |
+
)}
|
| 253 |
+
|
| 254 |
+
{/* PROBLEMS PANEL */}
|
| 255 |
+
{problems.length > 0 && (
|
| 256 |
+
<div className="ide-problems-panel">
|
| 257 |
+
<div>🚨 Problems ({problems.length})</div>
|
| 258 |
+
{problems.map((p, i) => (
|
| 259 |
+
<div key={i}>{p.file}:{p.line} — {p.message}</div>
|
| 260 |
+
))}
|
| 261 |
+
</div>
|
| 262 |
+
)}
|
| 263 |
+
</div>
|
| 264 |
|
| 265 |
{/* ==== SEARCH PANEL ==== */}
|
| 266 |
{searchOpen && (
|