-
Notifications
You must be signed in to change notification settings - Fork 634
MAINT add skeleton frontend #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
romanlutz
wants to merge
12
commits into
Azure:main
Choose a base branch
from
romanlutz:romanlutz/co_pyrit_initial
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6aa4a62
copyrit first working version with localhost outside container
romanlutz 0dc4661
slim side and top bars, working text+image inputs, redesigned input box
romanlutz bd6e8b4
basic working version with single conversation and converters (not ye…
romanlutz cd5b5a9
history added, small fixes
romanlutz 5510a6c
Merge branch 'main' of https://github.com/Azure/PyRIT into romanlutz/…
romanlutz 146c75f
updates to make it work again, fix "new chat" bug and add ribbon
romanlutz 9bdcf3f
docker infrastructure and workflow for GH push to ACR, small bugfix f…
romanlutz 89369c6
Merge branch 'main' of https://github.com/Azure/PyRIT into romanlutz/…
romanlutz 6caf221
Merge branch 'main' of https://github.com/Azure/PyRIT into romanlutz/…
romanlutz e3f6ecc
reduce to minimal frontend for PR
romanlutz da2e6f9
linting
romanlutz a2593a4
Merge branch 'main' into romanlutz/co_pyrit_initial
romanlutz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Dependencies | ||
| node_modules/ | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| # Build outputs | ||
| dist/ | ||
| dist-ssr/ | ||
| *.local | ||
|
|
||
| # Editor | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea/ | ||
| .DS_Store | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # PyRIT Frontend | ||
|
|
||
| Modern TypeScript + React frontend for PyRIT, built with Fluent UI. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Installation | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| ### Running the Frontend | ||
|
|
||
| ```bash | ||
| # Start the frontend server | ||
| python dev.py start | ||
|
|
||
| # Stop the frontend server | ||
| python dev.py stop | ||
|
|
||
| # Restart the frontend server | ||
| python dev.py restart | ||
| ``` | ||
|
|
||
| The frontend will be available at `http://localhost:3000` | ||
|
|
||
| ### Alternative: Using npm directly | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ### Building for Production | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| The built files will be in the `dist/` directory. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - **React 18** - UI framework | ||
| - **TypeScript** - Type safety | ||
| - **Fluent UI v9** - Microsoft design system | ||
| - **Vite** - Fast build tool | ||
| Configure this in `vite.config.ts` if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| """ | ||
| Minimal script to manage PyRIT frontend (no backend) | ||
| """ | ||
|
|
||
| import platform | ||
| import subprocess | ||
| import sys | ||
| import time | ||
| from pathlib import Path | ||
|
|
||
| # Determine workspace root (parent of frontend directory) | ||
| FRONTEND_DIR = Path(__file__).parent.absolute() | ||
|
|
||
|
|
||
| def is_windows(): | ||
| return platform.system() == "Windows" | ||
|
|
||
|
|
||
| def kill_process_by_pattern(pattern): | ||
| """Kill processes matching a pattern (cross-platform)""" | ||
| try: | ||
| if is_windows(): | ||
| # Windows: use taskkill | ||
| subprocess.run( | ||
| f'taskkill /F /FI "COMMANDLINE like %{pattern}%" >nul 2>&1', | ||
| shell=True, | ||
| check=False, | ||
| ) | ||
| else: | ||
| # Unix: use pkill | ||
| subprocess.run(["pkill", "-f", pattern], check=False, stderr=subprocess.DEVNULL) | ||
| except Exception as e: | ||
| print(f"Warning: Could not kill {pattern}: {e}") | ||
|
|
||
|
|
||
| def stop_frontend(): | ||
| """Stop the frontend server""" | ||
| print("🛑 Stopping frontend...") | ||
| kill_process_by_pattern("vite") | ||
| time.sleep(1) | ||
| print("✅ Frontend stopped") | ||
|
|
||
|
|
||
| def start_frontend(): | ||
| """Start the Vite frontend""" | ||
| print("🎨 Starting minimal PyRIT frontend on port 3000...") | ||
| print(" (No backend - this is a standalone demo)") | ||
|
|
||
| # Start frontend process | ||
| npm_cmd = "npm.cmd" if is_windows() else "npm" | ||
|
|
||
| if is_windows(): | ||
| frontend = subprocess.Popen( | ||
| [npm_cmd, "run", "dev"], | ||
| cwd=FRONTEND_DIR, | ||
| creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, | ||
| ) | ||
| else: | ||
| frontend = subprocess.Popen([npm_cmd, "run", "dev"], cwd=FRONTEND_DIR) | ||
|
|
||
| time.sleep(2) | ||
| print() | ||
| print("✅ Frontend running!") | ||
| print(f" URL: http://localhost:3000 (PID: {frontend.pid})") | ||
| print() | ||
| print("Press Ctrl+C to stop") | ||
|
|
||
| return frontend | ||
|
|
||
|
|
||
| def wait_for_interrupt(frontend): | ||
| """Wait for user interrupt and cleanup""" | ||
| try: | ||
| frontend.wait() | ||
| except KeyboardInterrupt: | ||
| print() | ||
| print("🛑 Stopping frontend...") | ||
|
|
||
| try: | ||
| if not is_windows(): | ||
| frontend.terminate() | ||
| frontend.wait(timeout=5) | ||
| except: # noqa: E722 | ||
| frontend.kill() | ||
|
|
||
| print("✅ Frontend stopped") | ||
|
|
||
|
|
||
| def main(): | ||
| """Main entry point""" | ||
| if len(sys.argv) > 1: | ||
| command = sys.argv[1].lower() | ||
|
|
||
| if command == "stop": | ||
| stop_frontend() | ||
| return | ||
| elif command == "restart": | ||
| stop_frontend() | ||
| time.sleep(1) | ||
| elif command in ["start", "frontend"]: | ||
| pass # Start frontend | ||
| else: | ||
| print(f"Unknown command: {command}") | ||
| print("Usage: python dev.py [start|stop|restart]") | ||
| sys.exit(1) | ||
|
|
||
| # Start frontend | ||
| frontend = start_frontend() | ||
|
|
||
| # Wait for interrupt | ||
| wait_for_interrupt(frontend) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>PyRIT - Python Risk Identification Tool</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering; do you think the existing
clicode should go in frontend? I think so, but curious what you think