Skip to content
Open
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
113 changes: 57 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
{
"name": "term",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"preview": "vite preview",
"test": "vitest run",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,md}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,md}\"",
"format:rust": "cd src-tauri && cargo fmt --all",
"format:all": "npm run format && npm run format:rust",
"prepare": "husky"
},
"dependencies": {
"eslint-define-config": "^2.1.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
"@tauri-apps/api": "^2.5.0",
"@tauri-apps/cli": "^2.5.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/jest": "^29.5.14",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"@vitest/coverage-v8": "3.1.4",
"autoprefixer": "^10.4.21",
"eslint": "^9.25.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^26.1.0",
"lint-staged": "^16.0.0",
"postcss": "^8.5.3",
"prettier": "^3.2.5",
"tailwindcss": "^3.4.17",
"ts-jest": "^29.3.4",
"typescript": "~5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.3.5",
"vitest": "^3.1.4"
},
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
"name": "term",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"preview": "vite preview",
"test": "vitest run",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,md}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,md}\"",
"format:rust": "cd src-tauri && cargo fmt --all",
"format:all": "npm run format && npm run format:rust",
"prepare": "husky"
},
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-markdown": "^8.0.7",
"eslint-define-config": "^2.1.0"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
"@tauri-apps/api": "^2.5.0",
"@tauri-apps/cli": "^2.5.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/jest": "^29.5.14",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"@vitest/coverage-v8": "3.1.4",
"autoprefixer": "^10.4.21",
"eslint": "^9.25.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^26.1.0",
"lint-staged": "^16.0.0",
"postcss": "^8.5.6",
"prettier": "^3.2.5",
"tailwindcss": "^3.4.17",
"ts-jest": "^29.3.4",
"typescript": "~5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.3.5",
"vitest": "^3.1.4"
},
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
}
31 changes: 29 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
import './App.css';
import Terminal from './components/Terminal';
import './App.css';

const exampleResponse = `
# AI Summary
Here is some **bold text** and *italic text*.
- Bullet Point 1
- Bullet Point 2
\`\`\`javascript
console.log("Code block test");
\`\`\`
⚠️ Error Message:
\x1b[31merror\x1b[0m Something went wrong!
`;

const malformedResponse = `
### Unclosed *italic*
**Bold without closing
- List item
`;

function App() {
return <Terminal />;
return (
<div className="h-screen w-full bg-gray-950 text-white p-4 space-y-4">
{/* ✅ Use both to remove warning and test */}
<Terminal aiResponse={exampleResponse} />
<Terminal aiResponse={malformedResponse} />
</div>
);
Comment on lines -5 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you’ve swapped the actual terminal for a demo version here - this breaks the real app flow. we shouldn’t be hardcoding markdown props into ; markdown rendering needs to work inside the real terminal output from the AI responses.

}

export default App;
73 changes: 73 additions & 0 deletions src/components/Terminal.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn’t the actual terminal component - the real one is in components/Terminal/index.tsx and handles input, history, command execution, and AI response handling. this new file isn’t used in the app and doesn’t integrate with anything.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { useState } from 'react';
import ReactMarkdown from 'react-markdown';

interface Message {
type: 'command' | 'output' | 'error' | 'llm';
text: string;
}

interface TerminalProps {
aiResponse?: string; // ✅ Optional prop
}

// ✅ Function to strip ANSI escape codes
function stripAnsi(input: string): string {
return input.replace(/\x1b\[[0-9;]*m/g, '');
}

export default function Terminal({ aiResponse }: TerminalProps) {
// ✅ Initialize state properly with lazy function to avoid re-runs
const [messages] = useState<Message[]>(() =>
aiResponse
? [{ type: 'llm', text: aiResponse }]
: [
{
type: 'llm',
text: `
# AI Response Example
This is **bold**, _italic_, and a list:

- First item
- Second item

Code block:
\`\`\`javascript
console.log("Hello Markdown!");
\`\`\`

⚠️ Error Test:
\x1b[31merror\x1b[0m Something went wrong!

### Malformed Markdown Test
**Bold without close
_Unclosed italic
`,
},
]
);

return (
<div className="terminal-container bg-gray-900 text-white p-4 rounded-lg">
<div className="terminal-output space-y-2">
{messages.map((msg, idx) => (
<div key={idx} className={`terminal-line ${msg.type}`}>
{msg.type === 'llm' ? (
<ReactMarkdown className="prose prose-invert max-w-none">
{stripAnsi(msg.text)}
</ReactMarkdown>
) : (
msg.text
)}
</div>
))}
</div>
<div className="terminal-input mt-2">
<input
className="font-mono w-full bg-black text-white p-2 rounded"
placeholder="Type a command..."
disabled
/>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
error: '#e06c75',
llm: '#98c379',
prompt: '#61afef',
border: '#333',
border: '#333'
}
},
fontFamily: {
Expand Down
1 change: 1 addition & 0 deletions term
Submodule term added at f40091