Spaces:
Runtime error
Runtime error
changed the project structure and ui , updated security and enhanced the project
Browse files- .claude/settings.local.json +15 -1
- .env.example +7 -1
- Current UI/Screenshot 2026-05-01 135942.png +0 -3
- Current UI/Screenshot 2026-05-01 140023.png +0 -3
- Current UI/Screenshot 2026-05-01 140040.png +0 -3
- Current UI/Screenshot 2026-05-01 140058.png +0 -3
- Current UI/Screenshot 2026-05-01 140111.png +0 -3
- Current UI/Screenshot 2026-05-01 140124.png +0 -3
- Current UI/Screenshot 2026-05-01 140140.png +0 -3
- Old Chats claude/1.md +0 -2
- Plans/old chats.md +2 -0
- Plans/plan 3.md +125 -167
- Plans/plan 4.md +444 -0
- alembic.ini +41 -0
- alembic/env.py +55 -0
- alembic/script.py.mako +26 -0
- alembic/versions/a1b2c3d4e5f6_initial.py +156 -0
- backend/app/api/routes/assets.py +2 -0
- backend/app/api/routes/chat.py +4 -0
- backend/app/api/routes/execution.py +10 -0
- backend/app/api/routes/usage.py +60 -0
- backend/core/config.py +7 -0
- backend/database.py +18 -16
- backend/integrations/llm/base.py +8 -0
- backend/integrations/llm/client.py +34 -10
- backend/main.py +3 -3
- backend/services/asset_service.py +44 -2
- backend/services/chat_assistant.py +4 -2
- backend/services/usage_service.py +48 -0
- frontend-react/index.html +5 -2
- frontend-react/src/App.jsx +52 -795
- frontend-react/src/components/CollectionsPage.jsx +119 -64
- frontend-react/src/index.css +843 -28
- frontend-react/src/pages/WorkflowPage.jsx +739 -0
- requirements.txt +2 -0
.claude/settings.local.json
CHANGED
|
@@ -7,7 +7,21 @@
|
|
| 7 |
"Bash(python -c \"from backend.main import app; from backend.core.url_guard import assert_safe_url; print\\('OK routes:', len\\(app.routes\\)\\)\")",
|
| 8 |
"Bash(python -c \"from backend.main import app; from backend.core.errors import AppError; print\\('OK routes:', len\\(app.routes\\)\\)\")",
|
| 9 |
"Bash(Get-ChildItem -Path \"C:\\\\Users\\\\amitk\\\\OneDrive\\\\Desktop\\\\Testing\" -Recurse -Directory)",
|
| 10 |
-
"Bash(Select-Object -ExpandProperty FullName)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
]
|
| 12 |
}
|
| 13 |
}
|
|
|
|
| 7 |
"Bash(python -c \"from backend.main import app; from backend.core.url_guard import assert_safe_url; print\\('OK routes:', len\\(app.routes\\)\\)\")",
|
| 8 |
"Bash(python -c \"from backend.main import app; from backend.core.errors import AppError; print\\('OK routes:', len\\(app.routes\\)\\)\")",
|
| 9 |
"Bash(Get-ChildItem -Path \"C:\\\\Users\\\\amitk\\\\OneDrive\\\\Desktop\\\\Testing\" -Recurse -Directory)",
|
| 10 |
+
"Bash(Select-Object -ExpandProperty FullName)",
|
| 11 |
+
"Bash(npm run *)",
|
| 12 |
+
"Bash(git rm *)",
|
| 13 |
+
"Bash(git add *)",
|
| 14 |
+
"Bash(git commit -m ' *)",
|
| 15 |
+
"Bash(pip show *)",
|
| 16 |
+
"PowerShell(Get-ChildItem -Path \"C:\\\\Users\\\\amitk\\\\OneDrive\\\\Desktop\\\\Testing\" -Force | Format-Table Name, @{Name=\"Type\";Expression={if \\($_.PSIsContainer\\) {\"Directory\"} else {\"File\"}}} -AutoSize)",
|
| 17 |
+
"Bash(Get-ChildItem -Path \"C:\\\\Users\\\\amitk\\\\OneDrive\\\\Desktop\\\\Testing\\\\backend\\\\app\\\\api\\\\routes\" -Filter \"*.py\")",
|
| 18 |
+
"Bash(Select-Object Name)",
|
| 19 |
+
"Bash(Format-List)",
|
| 20 |
+
"Bash(python -c \"import sys, json; d=json.load\\(sys.stdin\\); print\\(json.dumps\\({k: v for k, v in {**d.get\\('dependencies',{}\\), **d.get\\('devDependencies',{}\\)}.items\\(\\) if 'router' in k.lower\\(\\) or 'vite' in k.lower\\(\\) or 'react' in k.lower\\(\\)}, indent=2\\)\\)\")",
|
| 21 |
+
"Bash(python -c \"import ast, sys; content = open\\('backend/services/usage_service.py'\\).read\\(\\); ast.parse\\(content\\); print\\('usage_service.py: OK'\\)\")",
|
| 22 |
+
"Bash(python -c \"import ast, sys; content = open\\('backend/integrations/llm/base.py'\\).read\\(\\); ast.parse\\(content\\); print\\('base.py: OK'\\)\")",
|
| 23 |
+
"Bash(python -c \"import ast, sys; content = open\\('backend/integrations/llm/client.py'\\).read\\(\\); ast.parse\\(content\\); print\\('client.py: OK'\\)\")",
|
| 24 |
+
"Bash(python -c \"import ast; [print\\(f'{f}: OK'\\) or ast.parse\\(open\\(f\\).read\\(\\)\\) for f in ['backend/database.py','backend/main.py','backend/services/asset_service.py','backend/app/api/routes/execution.py','backend/app/api/routes/chat.py','backend/app/api/routes/usage.py','backend/core/config.py']]\")"
|
| 25 |
]
|
| 26 |
}
|
| 27 |
}
|
.env.example
CHANGED
|
@@ -1,5 +1,11 @@
|
|
| 1 |
MISTRAL_API_KEY=your_mistral_api_key_here
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@db.YOUR_PROJECT.supabase.co:5432/postgres
|
| 5 |
SUPABASE_URL=https://YOUR_PROJECT.supabase.co
|
|
|
|
| 1 |
MISTRAL_API_KEY=your_mistral_api_key_here
|
| 2 |
+
|
| 3 |
+
# LLM provider settings (Item 18)
|
| 4 |
+
LLM_MODEL=mistral-large-latest
|
| 5 |
+
LLM_FALLBACK_MODEL=open-mistral-7b
|
| 6 |
+
|
| 7 |
+
# Token budget per session β 0 = no limit (Item 17)
|
| 8 |
+
MAX_TOKENS_PER_SESSION=0
|
| 9 |
|
| 10 |
DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@db.YOUR_PROJECT.supabase.co:5432/postgres
|
| 11 |
SUPABASE_URL=https://YOUR_PROJECT.supabase.co
|
Current UI/Screenshot 2026-05-01 135942.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140023.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140040.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140058.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140111.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140124.png
DELETED
Git LFS Details
|
Current UI/Screenshot 2026-05-01 140140.png
DELETED
Git LFS Details
|
Old Chats claude/1.md
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
claude --resume b12b89ce-94d3-48fc-b8f8-b73ba5ddee29
|
| 2 |
-
claude --resume abc2b770-ce67-4c01-8f04-0e1e84cb120d , remaining
|
|
|
|
|
|
|
|
|
Plans/old chats.md
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
plan 3 first 2 phases : claude --resume ce5b1372-dfb2-450a-87e7-889931a723c2
|
| 2 |
+
<!-- claude --resume cd3a506a-2edb-4f4f-a957-bc7a352fc4c7 -->
|
Plans/plan 3.md
CHANGED
|
@@ -1,171 +1,129 @@
|
|
| 1 |
-
Phase 1 β Emergency Fixes
|
| 2 |
-
|
| 3 |
-
1. Remove binary uploads from git
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
*
|
| 59 |
-
*
|
| 60 |
-
*
|
| 61 |
-
*
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
*
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
*
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
*
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
*
|
| 102 |
-
*
|
| 103 |
-
*
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
*
|
| 108 |
-
|
| 109 |
-
*
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
*
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
*
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
*
|
| 123 |
-
|
| 124 |
-
* Make configurable via settings.
|
| 125 |
-
* For JSON, parse instead of slicing.
|
| 126 |
-
* Files: backend/services/response_analyzer.py, backend/core/config.py
|
| 127 |
-
|
| 128 |
-
Phase 4 β Architecture Improvements (Week 3β4)
|
| 129 |
-
|
| 130 |
-
16. Add file type validation (magic bytes)
|
| 131 |
-
|
| 132 |
-
* Files are validated only by extension.
|
| 133 |
-
* Install python-magic.
|
| 134 |
-
* Detect MIME type after upload.
|
| 135 |
-
* Compare with allowed types.
|
| 136 |
-
* Delete and reject if mismatch.
|
| 137 |
-
* Files: backend/services/asset_service.py, requirements.txt
|
| 138 |
-
|
| 139 |
-
17. Add LLM cost tracking and budget cap
|
| 140 |
-
|
| 141 |
-
* No tracking of token usage or cost.
|
| 142 |
-
* Create LLMUsage table.
|
| 143 |
-
* Store token usage for each call.
|
| 144 |
-
* Add /usage endpoint.
|
| 145 |
-
* Add max token limit per session.
|
| 146 |
-
* Files: backend/database.py, backend/services/, backend/app/api/routes/, backend/core/config.py
|
| 147 |
-
|
| 148 |
-
18. Abstract LLM client for provider fallback
|
| 149 |
-
|
| 150 |
-
* If Mistral fails, system has no backup.
|
| 151 |
-
* Create BaseLLMClient interface.
|
| 152 |
-
* Implement Mistral and another provider.
|
| 153 |
-
* Add config for primary and fallback.
|
| 154 |
-
* Retry with fallback on failure.
|
| 155 |
-
* Files: backend/integrations/llm/base.py, backend/integrations/llm/client.py, backend/core/config.py
|
| 156 |
-
|
| 157 |
-
19. Break up App.jsx (946 lines)
|
| 158 |
-
|
| 159 |
-
* App.jsx is 946 lines and handles too much logic.
|
| 160 |
-
* frontend-react/src/services/api.js already exists β move all API calls there.
|
| 161 |
-
* Separate component files already exist in src/components/ β keep and expand.
|
| 162 |
-
* Use react-router-dom (already installed) for page routing.
|
| 163 |
-
* Keep App.jsx only for routing and layout.
|
| 164 |
-
* Files: frontend-react/src/App.jsx, frontend-react/src/pages/, frontend-react/src/services/api.js
|
| 165 |
|
| 166 |
---
|
| 167 |
|
| 168 |
-
|
| 169 |
|
| 170 |
-
|
| 171 |
-
Item 1 β Item 2 β Item 7 β Item 13 β Item 14 β Item 10 β Item 8 β Items 9/12/15 β Item 4 β Items 3/5/6 (together) β Phase 4
|
|
|
|
| 1 |
+
Phase 1 β Emergency Fixes β
DONE
|
| 2 |
+
|
| 3 |
+
1. β
Remove binary uploads from git
|
| 4 |
+
- git rm --cached removed 3 tracked images from backend/uploads/documents/
|
| 5 |
+
- .gitignore upload patterns were already correct
|
| 6 |
+
|
| 7 |
+
2. β
Create .env.example
|
| 8 |
+
- .env was never committed to git β keys were never leaked
|
| 9 |
+
- .env.example created with placeholder values including new auth/crypto vars
|
| 10 |
+
- Real Supabase keys should still be rotated as best practice
|
| 11 |
+
|
| 12 |
+
Phase 2 β Security Hardening β
DONE
|
| 13 |
+
|
| 14 |
+
3. β
Add authentication to all endpoints
|
| 15 |
+
- backend/core/auth.py: create_access_token() + verify_token() (JWT via PyJWT)
|
| 16 |
+
- backend/app/api/routes/auth.py: POST /auth/login, GET /auth/me (public routes)
|
| 17 |
+
- backend/main.py: all API routers protected with Depends(verify_token)
|
| 18 |
+
- Config: AUTH_USERNAME, AUTH_PASSWORD, JWT_SECRET, JWT_EXPIRE_HOURS in .env
|
| 19 |
+
- Frontend: token held in module memory in api.js (never localStorage)
|
| 20 |
+
- axios interceptor attaches Bearer token; 401 broadcasts auth:logout event
|
| 21 |
+
- LoginPage.jsx shown before app loads when unauthenticated
|
| 22 |
+
|
| 23 |
+
4. β
Fix DNS rebinding SSRF bypass
|
| 24 |
+
- resolve_safe_ip() resolves hostname to IP once, blocks private ranges
|
| 25 |
+
- execution.py connects to the resolved IP directly with Host header pinned
|
| 26 |
+
- httpx can no longer re-resolve the hostname mid-flight
|
| 27 |
+
|
| 28 |
+
5. β
Encrypt stored credentials
|
| 29 |
+
- backend/core/crypto.py: encrypt_credentials() / decrypt_credentials() via Fernet
|
| 30 |
+
- Backwards-compatible: legacy plaintext dicts pass through unchanged on read
|
| 31 |
+
- specs.py: encrypts on save, decrypts on GET /credentials and GET /specs/:id
|
| 32 |
+
- execution.py: decrypts stored creds before passing to LLM planner and executor
|
| 33 |
+
- AI-suggested credentials also re-encrypted when merged into DB
|
| 34 |
+
- Requires ENCRYPTION_KEY in .env (Fernet key)
|
| 35 |
+
|
| 36 |
+
6. β
Tie sessions to authenticated users
|
| 37 |
+
- user_id column added to SessionModel and ChatSession (nullable)
|
| 38 |
+
- database.run_migrations(): ALTER TABLE IF NOT EXISTS stopgap (pre-Alembic)
|
| 39 |
+
- New sessions and chat sessions tagged with username from JWT
|
| 40 |
+
- Full per-user filtering deferred until Alembic migration is in place (Item 11)
|
| 41 |
+
|
| 42 |
+
7. β
Tighten CORS policy
|
| 43 |
+
- allow_methods changed to ['GET','POST','PUT','PATCH','DELETE']
|
| 44 |
+
- allow_headers changed to ['Content-Type','Authorization']
|
| 45 |
+
|
| 46 |
+
Phase 3 β Backend Reliability β
DONE
|
| 47 |
+
|
| 48 |
+
8. β
Fix event loop blocking in execute_step
|
| 49 |
+
- prepare_step_request() wrapped in asyncio.to_thread()
|
| 50 |
+
|
| 51 |
+
9. β
Add retry logic to api_executor
|
| 52 |
+
- parser.parse() retried once on failure; AppError raised after 2 failures
|
| 53 |
+
|
| 54 |
+
10. β
Fix mutable default arguments
|
| 55 |
+
- user_credentials and available_assets default to None, assigned {} inside function
|
| 56 |
+
|
| 57 |
+
11. β
Migrate from create_all() to Alembic
|
| 58 |
+
* alembic/ directory created at project root with env.py, script.py.mako
|
| 59 |
+
* alembic/versions/a1b2c3d4e5f6_initial.py: full initial schema including llm_usage
|
| 60 |
+
* alembic.ini configured to read DATABASE_URL from .env
|
| 61 |
+
* backend/database.py: added LLMUsage model; run_migrations() stopgap removed
|
| 62 |
+
* backend/main.py: run_migrations() call removed
|
| 63 |
+
* create_all() kept as safety net; replace with Alembic on new deployments:
|
| 64 |
+
- New deployment: alembic upgrade head
|
| 65 |
+
- Existing deployment: alembic stamp a1b2c3d4e5f6 && alembic upgrade head
|
| 66 |
+
* requirements.txt: alembic>=1.13.0 added
|
| 67 |
+
|
| 68 |
+
12. β
Fix DB host leak and debug prints
|
| 69 |
+
- print() calls replaced with logger in database.py and chat_assistant.py
|
| 70 |
+
|
| 71 |
+
13. β
Fix import inside except block
|
| 72 |
+
- import traceback moved to top of chat.py and specs.py
|
| 73 |
+
- traceback.print_exc() replaced with logger.error() throughout
|
| 74 |
+
|
| 75 |
+
14. β
Share the rate limiter across routers
|
| 76 |
+
- backend/core/limiter.py created with single shared Limiter instance
|
| 77 |
+
- chat.py and execution.py now import it instead of each creating their own
|
| 78 |
+
|
| 79 |
+
15. β
Increase response truncation limit
|
| 80 |
+
- Raised from 1000 to 4000 chars
|
| 81 |
+
- JSON responses are now parsed cleanly instead of sliced
|
| 82 |
+
- Configurable via RESPONSE_TRUNCATION_LIMIT in settings
|
| 83 |
+
|
| 84 |
+
Phase 4 β Architecture Improvements β
DONE
|
| 85 |
+
|
| 86 |
+
16. β
Add file type validation (magic bytes)
|
| 87 |
+
* filetype>=1.2.0 added to requirements.txt
|
| 88 |
+
* backend/services/asset_service.py: _ALLOWED_MIMES dict per category
|
| 89 |
+
* _validate_magic() reads first 1 KB with filetype.guess(); falls back to
|
| 90 |
+
extension check for text-based files (json, yaml, csv, txt β¦)
|
| 91 |
+
* upload_asset() rejects uploads where detected MIME doesn't match category
|
| 92 |
+
before saving to storage; raises ValueError with a clear message
|
| 93 |
+
|
| 94 |
+
17. β
Add LLM cost tracking and budget cap
|
| 95 |
+
* backend/database.py: LLMUsage ORM model (session_id, user_id, call_type,
|
| 96 |
+
prompt/completion/total_tokens, timestamp)
|
| 97 |
+
* backend/services/usage_service.py: log_usage(), get_session_total_tokens(),
|
| 98 |
+
check_budget() (raises AppError 429 when MAX_TOKENS_PER_SESSION exceeded)
|
| 99 |
+
* backend/app/api/routes/usage.py: GET /usage?session_id=&user_id= returns
|
| 100 |
+
per-call-type breakdown and totals
|
| 101 |
+
* execution.py: check_budget() before plan/step calls; log_usage() after each
|
| 102 |
+
* chat.py: log_usage() after each AI reply
|
| 103 |
+
* backend/core/config.py + .env.example: MAX_TOKENS_PER_SESSION (0 = no limit)
|
| 104 |
+
|
| 105 |
+
18. β
Abstract LLM client for provider fallback
|
| 106 |
+
* backend/integrations/llm/base.py: BaseLLMClient ABC with invoke() contract
|
| 107 |
+
* backend/integrations/llm/client.py: MistralClient(BaseLLMClient) +
|
| 108 |
+
FallbackLLMClient(primary, fallback) β retries with fallback on any exception
|
| 109 |
+
* _build_client() instantiates primary (LLM_MODEL) + optional fallback
|
| 110 |
+
(LLM_FALLBACK_MODEL) from config; same model = no fallback wrapper
|
| 111 |
+
* backend/core/config.py + .env.example: LLM_MODEL, LLM_FALLBACK_MODEL
|
| 112 |
+
|
| 113 |
+
19. β
Break up App.jsx (946 lines)
|
| 114 |
+
* frontend-react/src/pages/WorkflowPage.jsx (new): all workflow state & handlers
|
| 115 |
+
(handleGeneratePlan, executeStep, runAllSteps, handleOtpSubmit,
|
| 116 |
+
handleSelectionSubmit), execution plan UI, OTP/selection modals, scenario
|
| 117 |
+
composer, right panel (Context/AI tabs) with inline ChatAssistant
|
| 118 |
+
* frontend-react/src/App.jsx: reduced to routing + layout only (sidebar,
|
| 119 |
+
topbar with theme toggle, react-router-dom Routes)
|
| 120 |
+
* react-router-dom BrowserRouter wraps app; sidebar buttons use navigate();
|
| 121 |
+
nav-change events converted to navigate() calls
|
| 122 |
+
* /chat standalone page simplified: executeStepFromChat navigates to /workflow
|
| 123 |
+
(inline chat in WorkflowPage's right panel handles real execution)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
---
|
| 126 |
|
| 127 |
+
Status summary (as of 2026-05-03)
|
| 128 |
|
| 129 |
+
Done: All 19 items β
|
|
|
Plans/plan 4.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Plan 4 β Improvements
|
| 2 |
+
|
| 3 |
+
## Context for the AI reading this
|
| 4 |
+
|
| 5 |
+
This is a FastAPI + React project β an AI-powered API testing assistant.
|
| 6 |
+
Key files:
|
| 7 |
+
- `backend/app/api/routes/` β all route handlers
|
| 8 |
+
- `backend/services/` β business logic
|
| 9 |
+
- `backend/database.py` β all SQLAlchemy ORM models
|
| 10 |
+
- `backend/core/` β auth, config, crypto, limiter, logging, url_guard
|
| 11 |
+
- `backend/tests/` β pytest suite with SQLite in-memory DB
|
| 12 |
+
- `frontend-react/src/services/api.js` β all Axios calls
|
| 13 |
+
- `frontend-react/src/pages/WorkflowPage.jsx` β main workflow UI
|
| 14 |
+
- `frontend-react/src/components/` β all other pages/components
|
| 15 |
+
|
| 16 |
+
Do NOT change any logic that was intentionally implemented in plan_3.md.
|
| 17 |
+
Make minimal, targeted edits β do not refactor unrelated code.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Phase 1 β Quick Backend Fixes
|
| 22 |
+
|
| 23 |
+
### 1. Fix `datetime.utcnow` deprecation across `database.py`
|
| 24 |
+
|
| 25 |
+
**File:** `backend/database.py`
|
| 26 |
+
|
| 27 |
+
`datetime.utcnow` is deprecated since Python 3.12. Replace every occurrence with `datetime.now(timezone.utc)`.
|
| 28 |
+
|
| 29 |
+
Steps:
|
| 30 |
+
- Add `timezone` to the import: `from datetime import datetime, timezone`
|
| 31 |
+
- Replace every `default=datetime.utcnow` with `default=lambda: datetime.now(timezone.utc)`
|
| 32 |
+
- Affects columns in: `SpecDocument`, `SessionModel`, `ExecutionHistory`, `Collection`,
|
| 33 |
+
`Asset`, `ChatSession`, `ChatMessage`, `LLMUsage`
|
| 34 |
+
- Also replace `onupdate=datetime.utcnow` on `ChatSession.updated_at` with
|
| 35 |
+
`onupdate=lambda: datetime.now(timezone.utc)`
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
### 2. Rate limit `/analyze-response`
|
| 40 |
+
|
| 41 |
+
**File:** `backend/app/api/routes/execution.py`
|
| 42 |
+
|
| 43 |
+
`/plan` has `@limiter.limit("10/minute")` and `/execute-step` has `@limiter.limit("30/minute")`,
|
| 44 |
+
but `analyze_response_endpoint` has no rate limit despite calling the LLM.
|
| 45 |
+
|
| 46 |
+
Steps:
|
| 47 |
+
- Add `request: Request` as the first parameter to `analyze_response_endpoint`
|
| 48 |
+
(required by slowapi β same pattern as the other two endpoints in this file)
|
| 49 |
+
- Add `@limiter.limit("20/minute")` decorator above `@router.post("/analyze-response")`
|
| 50 |
+
- The limiter is already imported from `backend.core.limiter`
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
### 3. Per-user filtering on history and sessions
|
| 55 |
+
|
| 56 |
+
**File:** `backend/app/api/routes/history.py`
|
| 57 |
+
**File:** `backend/app/api/routes/sessions.py`
|
| 58 |
+
|
| 59 |
+
`user_id` column exists on `SessionModel` (added in plan_3 item 6) but queries don't filter by it.
|
| 60 |
+
`verify_token` returns the username string β inject it as `current_user`.
|
| 61 |
+
|
| 62 |
+
Steps in `history.py`:
|
| 63 |
+
- Add import: `from backend.core.auth import verify_token`
|
| 64 |
+
- Add `current_user: str = Depends(verify_token)` parameter to:
|
| 65 |
+
- `get_all_history()`
|
| 66 |
+
- `export_history_session()`
|
| 67 |
+
- `delete_history_session()`
|
| 68 |
+
- `clear_all_history()`
|
| 69 |
+
- In `get_all_history()`: add `.filter(database.SessionModel.user_id == current_user)`
|
| 70 |
+
to the existing join query (already joins `SessionModel`)
|
| 71 |
+
- In `export_history_session()`: after fetching `sess`, add:
|
| 72 |
+
```python
|
| 73 |
+
if sess.user_id and sess.user_id != current_user:
|
| 74 |
+
raise HTTPException(status_code=403, detail="Access denied")
|
| 75 |
+
```
|
| 76 |
+
- In `delete_history_session()`: same ownership check before deleting
|
| 77 |
+
- In `clear_all_history()`: filter the delete queries by joining sessions owned by
|
| 78 |
+
`current_user` instead of deleting everything:
|
| 79 |
+
```python
|
| 80 |
+
owned_ids = [
|
| 81 |
+
r[0] for r in db.query(database.SessionModel.id)
|
| 82 |
+
.filter(database.SessionModel.user_id == current_user).all()
|
| 83 |
+
]
|
| 84 |
+
db.query(database.ExecutionHistory).filter(
|
| 85 |
+
database.ExecutionHistory.session_id.in_(owned_ids)
|
| 86 |
+
).delete(synchronize_session=False)
|
| 87 |
+
db.query(database.SessionModel).filter(
|
| 88 |
+
database.SessionModel.id.in_(owned_ids)
|
| 89 |
+
).delete(synchronize_session=False)
|
| 90 |
+
db.commit()
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
Steps in `sessions.py`:
|
| 94 |
+
- `create_session()` already tags `user_id=current_user` β
|
| 95 |
+
- `clear_session()`: add `current_user: str = Depends(verify_token)` and check ownership:
|
| 96 |
+
```python
|
| 97 |
+
if session.user_id and session.user_id != current_user:
|
| 98 |
+
raise HTTPException(status_code=403, detail="Access denied")
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
### 4. Pagination on list endpoints
|
| 104 |
+
|
| 105 |
+
**Files:**
|
| 106 |
+
- `backend/app/api/routes/history.py` β `GET /history`
|
| 107 |
+
- `backend/app/api/routes/specs.py` β `GET /specs`
|
| 108 |
+
- `backend/app/api/routes/assets.py` β `GET /assets`
|
| 109 |
+
|
| 110 |
+
Add optional query params `limit: int = 50` and `offset: int = 0` to each list endpoint.
|
| 111 |
+
|
| 112 |
+
Pattern to apply to each:
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
# Add to function signature:
|
| 116 |
+
limit: int = 50, offset: int = 0
|
| 117 |
+
|
| 118 |
+
# Add to query before .all():
|
| 119 |
+
.offset(offset).limit(limit)
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
For `GET /history` specifically, also return total count so the frontend can show
|
| 123 |
+
"showing 50 of 200":
|
| 124 |
+
```python
|
| 125 |
+
total = db.query(database.ExecutionHistory).join(...).filter(...).count()
|
| 126 |
+
return {"items": [...], "total": total, "limit": limit, "offset": offset}
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
For `GET /specs` and `GET /assets`, a simple list return is fine β just slice it.
|
| 130 |
+
|
| 131 |
+
**Frontend** (`frontend-react/src/services/api.js`):
|
| 132 |
+
- `HistoryService.getHistory()`: add `params: { limit, offset }` (default 50/0)
|
| 133 |
+
- `SpecService.getAllSpecs()`: same
|
| 134 |
+
- `AssetService.getAllAssets()`: already accepts params β add `limit` and `offset`
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
### 5. Input size cap before LLM calls
|
| 139 |
+
|
| 140 |
+
**File:** `backend/app/api/routes/execution.py`
|
| 141 |
+
|
| 142 |
+
A user can send a 500KB scenario string straight into the LLM prompt, consuming huge
|
| 143 |
+
token budget. Add a guard at the top of both `generate_plan()` and `execute_step()`.
|
| 144 |
+
|
| 145 |
+
Add this helper at the top of `execution.py` (after imports):
|
| 146 |
+
```python
|
| 147 |
+
_MAX_SCENARIO_LEN = 50_000 # ~12k tokens worst case
|
| 148 |
+
|
| 149 |
+
def _check_input_sizes(**kwargs):
|
| 150 |
+
for name, value in kwargs.items():
|
| 151 |
+
if isinstance(value, str) and len(value) > _MAX_SCENARIO_LEN:
|
| 152 |
+
raise HTTPException(
|
| 153 |
+
status_code=400,
|
| 154 |
+
detail=f"Input field '{name}' exceeds maximum length of {_MAX_SCENARIO_LEN} characters."
|
| 155 |
+
)
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
In `generate_plan()`, call before the LLM:
|
| 159 |
+
```python
|
| 160 |
+
_check_input_sizes(scenario=body.scenario, spec_content=str(body.spec_content)[:1000])
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
In `execute_step()`, call before `prepare_step_request`:
|
| 164 |
+
```python
|
| 165 |
+
_check_input_sizes(scenario=body.step_definition.get("purpose", ""))
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## Phase 2 β Frontend Fixes
|
| 171 |
+
|
| 172 |
+
### 6. Persist JWT across page refreshes
|
| 173 |
+
|
| 174 |
+
**File:** `frontend-react/src/services/api.js`
|
| 175 |
+
|
| 176 |
+
Currently `_token` is a module-level variable β lost on every refresh, logging
|
| 177 |
+
the user out. Switch to `sessionStorage` (cleared when tab closes, survives refresh,
|
| 178 |
+
safer than `localStorage`).
|
| 179 |
+
|
| 180 |
+
Changes:
|
| 181 |
+
|
| 182 |
+
```js
|
| 183 |
+
// Replace the current module-level variable:
|
| 184 |
+
// let _token = null;
|
| 185 |
+
|
| 186 |
+
// With these two helpers:
|
| 187 |
+
const TOKEN_KEY = 'auth_token';
|
| 188 |
+
const getToken = () => sessionStorage.getItem(TOKEN_KEY);
|
| 189 |
+
const setToken = (t) => t ? sessionStorage.setItem(TOKEN_KEY, t) : sessionStorage.removeItem(TOKEN_KEY);
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
Then update all usages:
|
| 193 |
+
- `api.interceptors.request.use`: replace `if (_token)` with `if (getToken())`
|
| 194 |
+
and `config.headers.Authorization = \`Bearer ${_token}\`` with
|
| 195 |
+
`config.headers.Authorization = \`Bearer ${getToken()}\``
|
| 196 |
+
- `api.interceptors.response.use` error handler: replace `_token = null` with `setToken(null)`
|
| 197 |
+
- `AuthService.login()`: replace `_token = response.data.access_token` with
|
| 198 |
+
`setToken(response.data.access_token)`
|
| 199 |
+
- `AuthService.logout()`: replace `_token = null` with `setToken(null)`
|
| 200 |
+
- `AuthService.isAuthenticated()`: replace `return !!_token` with `return !!getToken()`
|
| 201 |
+
|
| 202 |
+
---
|
| 203 |
+
|
| 204 |
+
### 7. Fix 422 validation error display
|
| 205 |
+
|
| 206 |
+
**File:** `frontend-react/src/services/api.js`
|
| 207 |
+
|
| 208 |
+
FastAPI sends 422 errors as `{ detail: [{ loc, msg, type }] }` β an array.
|
| 209 |
+
The current interceptor does `error.response?.data?.detail` which returns
|
| 210 |
+
`[object Object]` when displayed.
|
| 211 |
+
|
| 212 |
+
In the response error interceptor, replace the `msg` extraction:
|
| 213 |
+
|
| 214 |
+
```js
|
| 215 |
+
// Replace:
|
| 216 |
+
const msg =
|
| 217 |
+
error.response?.data?.error ||
|
| 218 |
+
error.response?.data?.detail ||
|
| 219 |
+
error.message ||
|
| 220 |
+
'An unexpected error occurred.';
|
| 221 |
+
return Promise.reject(new Error(typeof msg === 'string' ? msg : JSON.stringify(msg)));
|
| 222 |
+
|
| 223 |
+
// With:
|
| 224 |
+
const raw = error.response?.data?.detail || error.response?.data?.error || error.message;
|
| 225 |
+
const msg = Array.isArray(raw)
|
| 226 |
+
? raw.map(e => `${e.loc?.slice(-1)[0] ?? 'field'}: ${e.msg}`).join(' | ')
|
| 227 |
+
: (typeof raw === 'string' ? raw : 'An unexpected error occurred.');
|
| 228 |
+
return Promise.reject(new Error(msg));
|
| 229 |
+
```
|
| 230 |
+
|
| 231 |
+
---
|
| 232 |
+
|
| 233 |
+
### 8. Disable buttons during API calls (loading state audit)
|
| 234 |
+
|
| 235 |
+
**File:** `frontend-react/src/pages/WorkflowPage.jsx`
|
| 236 |
+
|
| 237 |
+
Audit every button that triggers an async call. For each one, ensure:
|
| 238 |
+
- There is a `loading` state variable covering that action
|
| 239 |
+
- The button has `disabled={loading}` while in flight
|
| 240 |
+
- The button shows a visual indicator (spinner or text change like "Runningβ¦")
|
| 241 |
+
|
| 242 |
+
Specific buttons to check and fix if missing:
|
| 243 |
+
- "Generate Plan" button β should disable while `generatePlan()` is running
|
| 244 |
+
- "Execute Step" / "Run All" buttons β should disable while any step is executing
|
| 245 |
+
- "Save Credentials" / "Save Base URL" buttons β should disable on submit
|
| 246 |
+
|
| 247 |
+
Pattern to apply where missing:
|
| 248 |
+
```jsx
|
| 249 |
+
const [isGenerating, setIsGenerating] = useState(false);
|
| 250 |
+
|
| 251 |
+
const handleGeneratePlan = async () => {
|
| 252 |
+
setIsGenerating(true);
|
| 253 |
+
try {
|
| 254 |
+
await PlanService.generatePlan(payload);
|
| 255 |
+
} finally {
|
| 256 |
+
setIsGenerating(false); // always re-enables, even on error
|
| 257 |
+
}
|
| 258 |
+
};
|
| 259 |
+
|
| 260 |
+
// On button:
|
| 261 |
+
<button onClick={handleGeneratePlan} disabled={isGenerating}>
|
| 262 |
+
{isGenerating ? 'Generatingβ¦' : 'Generate Plan'}
|
| 263 |
+
</button>
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
The `finally` block is critical β without it, a failed request leaves the button
|
| 267 |
+
permanently disabled.
|
| 268 |
+
|
| 269 |
+
---
|
| 270 |
+
|
| 271 |
+
## Phase 3 β Test Coverage
|
| 272 |
+
|
| 273 |
+
### 9. Add auth tests to `test_routes.py`
|
| 274 |
+
|
| 275 |
+
**File:** `backend/tests/test_routes.py`
|
| 276 |
+
|
| 277 |
+
Currently `test_create_session` calls `POST /session` without a token and gets 200.
|
| 278 |
+
But `sessions.py` has `Depends(verify_token)` on that route β the test only passes
|
| 279 |
+
because the TestClient bypasses auth (conftest doesn't set up auth headers).
|
| 280 |
+
|
| 281 |
+
Add these tests:
|
| 282 |
+
|
| 283 |
+
```python
|
| 284 |
+
# ββ Auth βββββββββββββββββββββββββββββββββββββββββββββββββοΏ½οΏ½οΏ½ββββββββββββββββββββ
|
| 285 |
+
|
| 286 |
+
def test_login_success(client):
|
| 287 |
+
response = client.post("/auth/login", json={"username": "admin", "password": "changeme"})
|
| 288 |
+
assert response.status_code == 200
|
| 289 |
+
assert "access_token" in response.json()
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def test_login_wrong_password(client):
|
| 293 |
+
response = client.post("/auth/login", json={"username": "admin", "password": "wrong"})
|
| 294 |
+
assert response.status_code == 401
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def test_protected_route_without_token(client):
|
| 298 |
+
"""Any protected route must return 401 when no token is sent."""
|
| 299 |
+
response = client.get("/specs")
|
| 300 |
+
assert response.status_code == 401
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def test_protected_route_with_valid_token(client):
|
| 304 |
+
login = client.post("/auth/login", json={"username": "admin", "password": "changeme"})
|
| 305 |
+
token = login.json()["access_token"]
|
| 306 |
+
response = client.get("/specs", headers={"Authorization": f"Bearer {token}"})
|
| 307 |
+
assert response.status_code == 200
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def test_protected_route_with_invalid_token(client):
|
| 311 |
+
response = client.get("/specs", headers={"Authorization": "Bearer invalidtoken"})
|
| 312 |
+
assert response.status_code == 401
|
| 313 |
+
```
|
| 314 |
+
|
| 315 |
+
Also update `conftest.py` to set `AUTH_USERNAME` and `AUTH_PASSWORD` in env so
|
| 316 |
+
`test_login_success` works:
|
| 317 |
+
```python
|
| 318 |
+
os.environ.setdefault("AUTH_USERNAME", "admin")
|
| 319 |
+
os.environ.setdefault("AUTH_PASSWORD", "changeme")
|
| 320 |
+
os.environ.setdefault("JWT_SECRET", "test-secret")
|
| 321 |
+
```
|
| 322 |
+
|
| 323 |
+
---
|
| 324 |
+
|
| 325 |
+
### 10. Add budget cap test
|
| 326 |
+
|
| 327 |
+
**File:** `backend/tests/test_routes.py`
|
| 328 |
+
|
| 329 |
+
Add a test that verifies `check_budget()` blocks execution when the token cap is hit:
|
| 330 |
+
|
| 331 |
+
```python
|
| 332 |
+
def test_budget_cap_blocks_execution(client):
|
| 333 |
+
"""When MAX_TOKENS_PER_SESSION is exceeded, /plan must return 429."""
|
| 334 |
+
from unittest.mock import patch
|
| 335 |
+
from backend.core import config
|
| 336 |
+
|
| 337 |
+
login = client.post("/auth/login", json={"username": "admin", "password": "changeme"})
|
| 338 |
+
token = login.json()["access_token"]
|
| 339 |
+
headers = {"Authorization": f"Bearer {token}"}
|
| 340 |
+
|
| 341 |
+
session = client.post("/session", headers=headers).json()["session_id"]
|
| 342 |
+
|
| 343 |
+
# Temporarily set a token cap of 1 token
|
| 344 |
+
original_cap = config.settings.MAX_TOKENS_PER_SESSION
|
| 345 |
+
config.settings.MAX_TOKENS_PER_SESSION = 1
|
| 346 |
+
|
| 347 |
+
# Seed a usage record that exceeds the cap
|
| 348 |
+
from backend.tests.conftest import _TestingSession
|
| 349 |
+
from backend.database import LLMUsage
|
| 350 |
+
db = _TestingSession()
|
| 351 |
+
db.add(LLMUsage(session_id=session, call_type="plan", total_tokens=100))
|
| 352 |
+
db.commit()
|
| 353 |
+
db.close()
|
| 354 |
+
|
| 355 |
+
try:
|
| 356 |
+
response = client.post("/plan", headers=headers, json={
|
| 357 |
+
"spec_content": "{}",
|
| 358 |
+
"base_url": "https://example.com",
|
| 359 |
+
"scenario": "test",
|
| 360 |
+
"user_credentials": {},
|
| 361 |
+
})
|
| 362 |
+
assert response.status_code == 429
|
| 363 |
+
finally:
|
| 364 |
+
config.settings.MAX_TOKENS_PER_SESSION = original_cap
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
---
|
| 368 |
+
|
| 369 |
+
## Phase 4 β README
|
| 370 |
+
|
| 371 |
+
### 11. Write a proper README
|
| 372 |
+
|
| 373 |
+
**File:** `README.md` (project root β create if it doesn't exist)
|
| 374 |
+
|
| 375 |
+
Write a README with the following sections:
|
| 376 |
+
|
| 377 |
+
```markdown
|
| 378 |
+
# AI API Testing Assistant
|
| 379 |
+
|
| 380 |
+
An AI-powered API testing tool. Upload an OpenAPI/Postman spec, describe your
|
| 381 |
+
test scenario in plain language, and the AI generates and executes the test steps.
|
| 382 |
+
|
| 383 |
+
## What it does
|
| 384 |
+
- Parses OpenAPI 3.0 and Postman Collection v2 specs
|
| 385 |
+
- AI generates a step-by-step execution plan from a plain language scenario
|
| 386 |
+
- Executes each HTTP step, extracts context variables (tokens, IDs) automatically
|
| 387 |
+
- Chat assistant lets you modify, retry, and explain steps via natural language
|
| 388 |
+
- Media Hub for managing test assets (files, images) attached to requests
|
| 389 |
+
- LLM token usage tracking and budget cap per session
|
| 390 |
+
|
| 391 |
+
## Stack
|
| 392 |
+
- **Backend:** FastAPI, SQLAlchemy, PostgreSQL, Alembic, Mistral AI
|
| 393 |
+
- **Frontend:** React, Vite, Axios, React Router
|
| 394 |
+
|
| 395 |
+
## Setup
|
| 396 |
+
|
| 397 |
+
### 1. Environment
|
| 398 |
+
Copy `.env.example` to `.env` and fill in:
|
| 399 |
+
- `DATABASE_URL` β PostgreSQL connection string
|
| 400 |
+
- `MISTRAL_API_KEY` β from console.mistral.ai
|
| 401 |
+
- `JWT_SECRET` β any random 32+ char string
|
| 402 |
+
- `AUTH_USERNAME` / `AUTH_PASSWORD` β login credentials for the app
|
| 403 |
+
- `ENCRYPTION_KEY` β generate with: `python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"`
|
| 404 |
+
|
| 405 |
+
### 2. Database
|
| 406 |
+
New deployment:
|
| 407 |
+
alembic upgrade head
|
| 408 |
+
|
| 409 |
+
Existing deployment (stamping the initial migration):
|
| 410 |
+
alembic stamp a1b2c3d4e5f6 && alembic upgrade head
|
| 411 |
+
|
| 412 |
+
### 3. Backend
|
| 413 |
+
pip install -r requirements.txt
|
| 414 |
+
uvicorn backend.main:app --reload --port 8001
|
| 415 |
+
|
| 416 |
+
### 4. Frontend
|
| 417 |
+
cd frontend-react
|
| 418 |
+
npm install
|
| 419 |
+
npm run dev
|
| 420 |
+
|
| 421 |
+
### 5. Tests
|
| 422 |
+
pytest backend/tests/
|
| 423 |
+
|
| 424 |
+
## Single-user note
|
| 425 |
+
This app uses a single username/password set in `.env`. There is no user
|
| 426 |
+
registration. To change credentials, update `AUTH_USERNAME` and `AUTH_PASSWORD`
|
| 427 |
+
in your `.env` and restart the server.
|
| 428 |
+
```
|
| 429 |
+
|
| 430 |
+
---
|
| 431 |
+
|
| 432 |
+
## Done Checklist
|
| 433 |
+
|
| 434 |
+
- [ ] 1. `datetime.utcnow` β `datetime.now(timezone.utc)` in `database.py`
|
| 435 |
+
- [ ] 2. `@limiter.limit("20/minute")` on `analyze_response_endpoint` in `execution.py`
|
| 436 |
+
- [ ] 3. Per-user filtering in `history.py` and `sessions.py`
|
| 437 |
+
- [ ] 4. Pagination (`limit`/`offset`) on `/history`, `/specs`, `/assets` + frontend params
|
| 438 |
+
- [ ] 5. Input size cap (`_check_input_sizes`) in `execution.py`
|
| 439 |
+
- [ ] 6. `sessionStorage` token persistence in `api.js`
|
| 440 |
+
- [ ] 7. 422 array error formatting in `api.js`
|
| 441 |
+
- [ ] 8. Loading state audit on buttons in `WorkflowPage.jsx`
|
| 442 |
+
- [ ] 9. Auth tests in `test_routes.py` + env vars in `conftest.py`
|
| 443 |
+
- [ ] 10. Budget cap test in `test_routes.py`
|
| 444 |
+
- [ ] 11. `README.md` at project root
|
alembic.ini
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[alembic]
|
| 2 |
+
script_location = alembic
|
| 3 |
+
prepend_sys_path = .
|
| 4 |
+
# URL is set dynamically from DATABASE_URL env var in env.py
|
| 5 |
+
sqlalchemy.url =
|
| 6 |
+
|
| 7 |
+
[post_write_hooks]
|
| 8 |
+
|
| 9 |
+
[loggers]
|
| 10 |
+
keys = root,sqlalchemy,alembic
|
| 11 |
+
|
| 12 |
+
[handlers]
|
| 13 |
+
keys = console
|
| 14 |
+
|
| 15 |
+
[formatters]
|
| 16 |
+
keys = generic
|
| 17 |
+
|
| 18 |
+
[logger_root]
|
| 19 |
+
level = WARN
|
| 20 |
+
handlers = console
|
| 21 |
+
qualname =
|
| 22 |
+
|
| 23 |
+
[logger_sqlalchemy]
|
| 24 |
+
level = WARN
|
| 25 |
+
handlers =
|
| 26 |
+
qualname = sqlalchemy.engine
|
| 27 |
+
|
| 28 |
+
[logger_alembic]
|
| 29 |
+
level = INFO
|
| 30 |
+
handlers =
|
| 31 |
+
qualname = alembic
|
| 32 |
+
|
| 33 |
+
[handler_console]
|
| 34 |
+
class = StreamHandler
|
| 35 |
+
args = (sys.stderr,)
|
| 36 |
+
level = NOTSET
|
| 37 |
+
formatter = generic
|
| 38 |
+
|
| 39 |
+
[formatter_generic]
|
| 40 |
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
| 41 |
+
datefmt = %H:%M:%S
|
alembic/env.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from logging.config import fileConfig
|
| 4 |
+
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
from sqlalchemy import engine_from_config, pool
|
| 7 |
+
from alembic import context
|
| 8 |
+
|
| 9 |
+
# Load .env so DATABASE_URL is available before importing models
|
| 10 |
+
env_path = Path(__file__).resolve().parent.parent / ".env"
|
| 11 |
+
load_dotenv(dotenv_path=env_path)
|
| 12 |
+
|
| 13 |
+
# Import all models so Base.metadata is fully populated
|
| 14 |
+
from backend.database import Base, DATABASE_URL # noqa: F401
|
| 15 |
+
|
| 16 |
+
config = context.config
|
| 17 |
+
config.set_main_option("sqlalchemy.url", DATABASE_URL)
|
| 18 |
+
|
| 19 |
+
if config.config_file_name is not None:
|
| 20 |
+
fileConfig(config.config_file_name)
|
| 21 |
+
|
| 22 |
+
target_metadata = Base.metadata
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def run_migrations_offline() -> None:
|
| 26 |
+
url = config.get_main_option("sqlalchemy.url")
|
| 27 |
+
context.configure(
|
| 28 |
+
url=url,
|
| 29 |
+
target_metadata=target_metadata,
|
| 30 |
+
literal_binds=True,
|
| 31 |
+
dialect_opts={"paramstyle": "named"},
|
| 32 |
+
)
|
| 33 |
+
with context.begin_transaction():
|
| 34 |
+
context.run_migrations()
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def run_migrations_online() -> None:
|
| 38 |
+
connectable = engine_from_config(
|
| 39 |
+
config.get_section(config.config_ini_section, {}),
|
| 40 |
+
prefix="sqlalchemy.",
|
| 41 |
+
poolclass=pool.NullPool,
|
| 42 |
+
)
|
| 43 |
+
with connectable.connect() as connection:
|
| 44 |
+
context.configure(
|
| 45 |
+
connection=connection,
|
| 46 |
+
target_metadata=target_metadata,
|
| 47 |
+
)
|
| 48 |
+
with context.begin_transaction():
|
| 49 |
+
context.run_migrations()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if context.is_offline_mode():
|
| 53 |
+
run_migrations_offline()
|
| 54 |
+
else:
|
| 55 |
+
run_migrations_online()
|
alembic/script.py.mako
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""${message}
|
| 2 |
+
|
| 3 |
+
Revision ID: ${up_revision}
|
| 4 |
+
Revises: ${down_revision | comma,n}
|
| 5 |
+
Create Date: ${create_date}
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
${imports if imports else ""}
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = ${repr(up_revision)}
|
| 16 |
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
${upgrades if upgrades else "pass"}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def downgrade() -> None:
|
| 26 |
+
${downgrades if downgrades else "pass"}
|
alembic/versions/a1b2c3d4e5f6_initial.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Initial schema
|
| 2 |
+
|
| 3 |
+
Revision ID: a1b2c3d4e5f6
|
| 4 |
+
Revises:
|
| 5 |
+
Create Date: 2026-05-03
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
import sqlalchemy as sa
|
| 11 |
+
from alembic import op
|
| 12 |
+
|
| 13 |
+
revision: str = "a1b2c3d4e5f6"
|
| 14 |
+
down_revision: Union[str, None] = None
|
| 15 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 16 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def upgrade() -> None:
|
| 20 |
+
op.create_table(
|
| 21 |
+
"spec_documents",
|
| 22 |
+
sa.Column("id", sa.String(), nullable=False),
|
| 23 |
+
sa.Column("name", sa.String(), nullable=False),
|
| 24 |
+
sa.Column("raw_content", sa.Text(), nullable=False),
|
| 25 |
+
sa.Column("parsed_json", sa.JSON(), nullable=False),
|
| 26 |
+
sa.Column("base_url", sa.String(), nullable=True),
|
| 27 |
+
sa.Column("login_credentials", sa.JSON(), nullable=True),
|
| 28 |
+
sa.Column("execution_plan", sa.JSON(), nullable=True),
|
| 29 |
+
sa.Column("scenario", sa.Text(), nullable=True),
|
| 30 |
+
sa.Column("file_path", sa.String(), nullable=True),
|
| 31 |
+
sa.Column("uploaded_at", sa.DateTime(), nullable=True),
|
| 32 |
+
sa.PrimaryKeyConstraint("id"),
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
op.create_table(
|
| 36 |
+
"sessions",
|
| 37 |
+
sa.Column("id", sa.String(), nullable=False),
|
| 38 |
+
sa.Column("user_id", sa.String(), nullable=True),
|
| 39 |
+
sa.Column("spec_id", sa.String(), nullable=True),
|
| 40 |
+
sa.Column("spec_name", sa.String(), nullable=True),
|
| 41 |
+
sa.Column("base_url", sa.String(), nullable=True),
|
| 42 |
+
sa.Column("scenario", sa.Text(), nullable=True),
|
| 43 |
+
sa.Column("context_variables", sa.JSON(), nullable=True),
|
| 44 |
+
sa.Column("created_at", sa.DateTime(), nullable=True),
|
| 45 |
+
sa.ForeignKeyConstraint(["spec_id"], ["spec_documents.id"]),
|
| 46 |
+
sa.PrimaryKeyConstraint("id"),
|
| 47 |
+
)
|
| 48 |
+
op.create_index("ix_sessions_id", "sessions", ["id"])
|
| 49 |
+
op.create_index("ix_sessions_user_id", "sessions", ["user_id"])
|
| 50 |
+
|
| 51 |
+
op.create_table(
|
| 52 |
+
"execution_history",
|
| 53 |
+
sa.Column("id", sa.Integer(), nullable=False),
|
| 54 |
+
sa.Column("session_id", sa.String(), nullable=True),
|
| 55 |
+
sa.Column("step", sa.Integer(), nullable=True),
|
| 56 |
+
sa.Column("request_json", sa.JSON(), nullable=True),
|
| 57 |
+
sa.Column("response_json", sa.JSON(), nullable=True),
|
| 58 |
+
sa.Column("analysis_json", sa.JSON(), nullable=True),
|
| 59 |
+
sa.Column("step_definition_json", sa.JSON(), nullable=True),
|
| 60 |
+
sa.Column("timestamp", sa.DateTime(), nullable=True),
|
| 61 |
+
sa.PrimaryKeyConstraint("id"),
|
| 62 |
+
)
|
| 63 |
+
op.create_index("ix_execution_history_id", "execution_history", ["id"])
|
| 64 |
+
op.create_index("ix_execution_history_session_id", "execution_history", ["session_id"])
|
| 65 |
+
op.create_index("ix_execution_history_step", "execution_history", ["step"])
|
| 66 |
+
|
| 67 |
+
op.create_table(
|
| 68 |
+
"collections",
|
| 69 |
+
sa.Column("id", sa.String(), nullable=False),
|
| 70 |
+
sa.Column("name", sa.String(), nullable=False),
|
| 71 |
+
sa.Column("description", sa.Text(), nullable=True),
|
| 72 |
+
sa.Column("spec_id", sa.String(), nullable=True),
|
| 73 |
+
sa.Column("created_at", sa.DateTime(), nullable=True),
|
| 74 |
+
sa.ForeignKeyConstraint(["spec_id"], ["spec_documents.id"]),
|
| 75 |
+
sa.PrimaryKeyConstraint("id"),
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
op.create_table(
|
| 79 |
+
"assets",
|
| 80 |
+
sa.Column("id", sa.String(), nullable=False),
|
| 81 |
+
sa.Column("name", sa.String(), nullable=False),
|
| 82 |
+
sa.Column("file_type", sa.String(), nullable=False),
|
| 83 |
+
sa.Column("file_path", sa.String(), nullable=False),
|
| 84 |
+
sa.Column("file_size", sa.Integer(), nullable=True),
|
| 85 |
+
sa.Column("category", sa.String(), nullable=True),
|
| 86 |
+
sa.Column("description", sa.Text(), nullable=True),
|
| 87 |
+
sa.Column("tags", sa.JSON(), nullable=True),
|
| 88 |
+
sa.Column("metadata_json", sa.JSON(), nullable=True),
|
| 89 |
+
sa.Column("spec_id", sa.String(), nullable=True),
|
| 90 |
+
sa.Column("uploaded_at", sa.DateTime(), nullable=True),
|
| 91 |
+
sa.ForeignKeyConstraint(["spec_id"], ["spec_documents.id"]),
|
| 92 |
+
sa.PrimaryKeyConstraint("id"),
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
op.create_table(
|
| 96 |
+
"asset_collections",
|
| 97 |
+
sa.Column("asset_id", sa.String(), nullable=False),
|
| 98 |
+
sa.Column("collection_id", sa.String(), nullable=False),
|
| 99 |
+
sa.ForeignKeyConstraint(["asset_id"], ["assets.id"]),
|
| 100 |
+
sa.ForeignKeyConstraint(["collection_id"], ["collections.id"]),
|
| 101 |
+
sa.PrimaryKeyConstraint("asset_id", "collection_id"),
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
op.create_table(
|
| 105 |
+
"chat_sessions",
|
| 106 |
+
sa.Column("id", sa.String(), nullable=False),
|
| 107 |
+
sa.Column("user_id", sa.String(), nullable=True),
|
| 108 |
+
sa.Column("name", sa.String(), nullable=False),
|
| 109 |
+
sa.Column("spec_id", sa.String(), nullable=True),
|
| 110 |
+
sa.Column("session_id", sa.String(), nullable=True),
|
| 111 |
+
sa.Column("created_at", sa.DateTime(), nullable=True),
|
| 112 |
+
sa.Column("updated_at", sa.DateTime(), nullable=True),
|
| 113 |
+
sa.ForeignKeyConstraint(["spec_id"], ["spec_documents.id"], ondelete="SET NULL"),
|
| 114 |
+
sa.PrimaryKeyConstraint("id"),
|
| 115 |
+
)
|
| 116 |
+
op.create_index("ix_chat_sessions_user_id", "chat_sessions", ["user_id"])
|
| 117 |
+
|
| 118 |
+
op.create_table(
|
| 119 |
+
"chat_messages",
|
| 120 |
+
sa.Column("id", sa.Integer(), nullable=False),
|
| 121 |
+
sa.Column("chat_session_id", sa.String(), nullable=False),
|
| 122 |
+
sa.Column("role", sa.String(), nullable=False),
|
| 123 |
+
sa.Column("content", sa.Text(), nullable=False),
|
| 124 |
+
sa.Column("action_json", sa.JSON(), nullable=True),
|
| 125 |
+
sa.Column("timestamp", sa.DateTime(), nullable=True),
|
| 126 |
+
sa.ForeignKeyConstraint(["chat_session_id"], ["chat_sessions.id"], ondelete="CASCADE"),
|
| 127 |
+
sa.PrimaryKeyConstraint("id"),
|
| 128 |
+
)
|
| 129 |
+
op.create_index("ix_chat_messages_id", "chat_messages", ["id"])
|
| 130 |
+
|
| 131 |
+
op.create_table(
|
| 132 |
+
"llm_usage",
|
| 133 |
+
sa.Column("id", sa.Integer(), nullable=False),
|
| 134 |
+
sa.Column("session_id", sa.String(), nullable=True),
|
| 135 |
+
sa.Column("user_id", sa.String(), nullable=True),
|
| 136 |
+
sa.Column("call_type", sa.String(), nullable=False),
|
| 137 |
+
sa.Column("prompt_tokens", sa.Integer(), nullable=True),
|
| 138 |
+
sa.Column("completion_tokens", sa.Integer(), nullable=True),
|
| 139 |
+
sa.Column("total_tokens", sa.Integer(), nullable=True),
|
| 140 |
+
sa.Column("timestamp", sa.DateTime(), nullable=True),
|
| 141 |
+
sa.PrimaryKeyConstraint("id"),
|
| 142 |
+
)
|
| 143 |
+
op.create_index("ix_llm_usage_id", "llm_usage", ["id"])
|
| 144 |
+
op.create_index("ix_llm_usage_session_id", "llm_usage", ["session_id"])
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def downgrade() -> None:
|
| 148 |
+
op.drop_table("llm_usage")
|
| 149 |
+
op.drop_table("chat_messages")
|
| 150 |
+
op.drop_table("chat_sessions")
|
| 151 |
+
op.drop_table("asset_collections")
|
| 152 |
+
op.drop_table("assets")
|
| 153 |
+
op.drop_table("collections")
|
| 154 |
+
op.drop_table("execution_history")
|
| 155 |
+
op.drop_table("sessions")
|
| 156 |
+
op.drop_table("spec_documents")
|
backend/app/api/routes/assets.py
CHANGED
|
@@ -34,6 +34,8 @@ async def upload_asset(
|
|
| 34 |
"spec_id": asset.spec_id,
|
| 35 |
"uploaded_at": asset.uploaded_at.isoformat(),
|
| 36 |
}
|
|
|
|
|
|
|
| 37 |
except Exception as e:
|
| 38 |
raise HTTPException(status_code=500, detail=f"Upload failed: {str(e)}")
|
| 39 |
|
|
|
|
| 34 |
"spec_id": asset.spec_id,
|
| 35 |
"uploaded_at": asset.uploaded_at.isoformat(),
|
| 36 |
}
|
| 37 |
+
except ValueError as e:
|
| 38 |
+
raise HTTPException(status_code=422, detail=str(e))
|
| 39 |
except Exception as e:
|
| 40 |
raise HTTPException(status_code=500, detail=f"Upload failed: {str(e)}")
|
| 41 |
|
backend/app/api/routes/chat.py
CHANGED
|
@@ -11,6 +11,7 @@ from backend.core.auth import verify_token
|
|
| 11 |
from backend.core.limiter import limiter
|
| 12 |
from backend.core.logging import get_logger
|
| 13 |
from backend.services.chat_assistant import process_message as chat_process_message
|
|
|
|
| 14 |
|
| 15 |
router = APIRouter()
|
| 16 |
logger = get_logger(__name__)
|
|
@@ -74,6 +75,9 @@ def chat_endpoint(
|
|
| 74 |
chat_history=chat_history,
|
| 75 |
)
|
| 76 |
|
|
|
|
|
|
|
|
|
|
| 77 |
assistant_content = ai_result.get("message", "")
|
| 78 |
db.add(database.ChatMessage(
|
| 79 |
chat_session_id=chat_session.id,
|
|
|
|
| 11 |
from backend.core.limiter import limiter
|
| 12 |
from backend.core.logging import get_logger
|
| 13 |
from backend.services.chat_assistant import process_message as chat_process_message
|
| 14 |
+
from backend.services.usage_service import log_usage
|
| 15 |
|
| 16 |
router = APIRouter()
|
| 17 |
logger = get_logger(__name__)
|
|
|
|
| 75 |
chat_history=chat_history,
|
| 76 |
)
|
| 77 |
|
| 78 |
+
token_usage = ai_result.pop("_token_usage", None)
|
| 79 |
+
log_usage(db, body.session_id, current_user, "chat", token_usage)
|
| 80 |
+
|
| 81 |
assistant_content = ai_result.get("message", "")
|
| 82 |
db.add(database.ChatMessage(
|
| 83 |
chat_session_id=chat_session.id,
|
backend/app/api/routes/execution.py
CHANGED
|
@@ -20,6 +20,7 @@ from backend.services.asset_service import AssetService, storage
|
|
| 20 |
from backend.services.context_manager import set_context_variables
|
| 21 |
from backend.services.llm_planner import generate_execution_plan
|
| 22 |
from backend.services.response_analyzer import analyze_api_response
|
|
|
|
| 23 |
|
| 24 |
router = APIRouter()
|
| 25 |
logger = get_logger(__name__)
|
|
@@ -94,6 +95,8 @@ def _is_placeholder(url: str) -> bool:
|
|
| 94 |
@limiter.limit("10/minute")
|
| 95 |
def generate_plan(request: Request, body: schemas.PlanRequest, db: Session = Depends(database.get_db)):
|
| 96 |
try:
|
|
|
|
|
|
|
| 97 |
parsed_spec = json.loads(body.spec_content) if isinstance(body.spec_content, str) else body.spec_content
|
| 98 |
|
| 99 |
credentials = body.user_credentials or {}
|
|
@@ -103,6 +106,7 @@ def generate_plan(request: Request, body: schemas.PlanRequest, db: Session = Dep
|
|
| 103 |
credentials = decrypt_credentials(spec.login_credentials)
|
| 104 |
|
| 105 |
plan = generate_execution_plan(parsed_spec, body.base_url, body.scenario, credentials)
|
|
|
|
| 106 |
|
| 107 |
if body.spec_id:
|
| 108 |
spec = db.query(database.SpecDocument).filter(database.SpecDocument.id == body.spec_id).first()
|
|
@@ -141,6 +145,8 @@ def generate_plan(request: Request, body: schemas.PlanRequest, db: Session = Dep
|
|
| 141 |
@limiter.limit("30/minute")
|
| 142 |
async def execute_step(request: Request, body: schemas.ExecuteStepRequest, db: Session = Depends(database.get_db)):
|
| 143 |
try:
|
|
|
|
|
|
|
| 144 |
endpoint_str = body.step_definition.get("endpoint", "")
|
| 145 |
actual_endpoint_spec = {"endpoint": endpoint_str}
|
| 146 |
|
|
@@ -308,6 +314,8 @@ async def execute_step(request: Request, body: schemas.ExecuteStepRequest, db: S
|
|
| 308 |
))
|
| 309 |
db.commit()
|
| 310 |
|
|
|
|
|
|
|
| 311 |
return {
|
| 312 |
"executed_request": req_plan.request.model_dump(),
|
| 313 |
"response": resp_data,
|
|
@@ -331,6 +339,8 @@ def analyze_response_endpoint(request: schemas.AnalyzeRequest, db: Session = Dep
|
|
| 331 |
response_body=request.response_data.get("body", ""),
|
| 332 |
)
|
| 333 |
|
|
|
|
|
|
|
| 334 |
if analysis.extracted_variables:
|
| 335 |
set_context_variables(db, request.session_id, analysis.extracted_variables)
|
| 336 |
|
|
|
|
| 20 |
from backend.services.context_manager import set_context_variables
|
| 21 |
from backend.services.llm_planner import generate_execution_plan
|
| 22 |
from backend.services.response_analyzer import analyze_api_response
|
| 23 |
+
from backend.services.usage_service import check_budget, log_usage
|
| 24 |
|
| 25 |
router = APIRouter()
|
| 26 |
logger = get_logger(__name__)
|
|
|
|
| 95 |
@limiter.limit("10/minute")
|
| 96 |
def generate_plan(request: Request, body: schemas.PlanRequest, db: Session = Depends(database.get_db)):
|
| 97 |
try:
|
| 98 |
+
check_budget(db, body.session_id)
|
| 99 |
+
|
| 100 |
parsed_spec = json.loads(body.spec_content) if isinstance(body.spec_content, str) else body.spec_content
|
| 101 |
|
| 102 |
credentials = body.user_credentials or {}
|
|
|
|
| 106 |
credentials = decrypt_credentials(spec.login_credentials)
|
| 107 |
|
| 108 |
plan = generate_execution_plan(parsed_spec, body.base_url, body.scenario, credentials)
|
| 109 |
+
log_usage(db, body.session_id, None, "plan", plan.token_usage.model_dump() if plan.token_usage else None)
|
| 110 |
|
| 111 |
if body.spec_id:
|
| 112 |
spec = db.query(database.SpecDocument).filter(database.SpecDocument.id == body.spec_id).first()
|
|
|
|
| 145 |
@limiter.limit("30/minute")
|
| 146 |
async def execute_step(request: Request, body: schemas.ExecuteStepRequest, db: Session = Depends(database.get_db)):
|
| 147 |
try:
|
| 148 |
+
check_budget(db, body.session_id)
|
| 149 |
+
|
| 150 |
endpoint_str = body.step_definition.get("endpoint", "")
|
| 151 |
actual_endpoint_spec = {"endpoint": endpoint_str}
|
| 152 |
|
|
|
|
| 314 |
))
|
| 315 |
db.commit()
|
| 316 |
|
| 317 |
+
log_usage(db, body.session_id, None, "execute_step", executor_token_usage)
|
| 318 |
+
|
| 319 |
return {
|
| 320 |
"executed_request": req_plan.request.model_dump(),
|
| 321 |
"response": resp_data,
|
|
|
|
| 339 |
response_body=request.response_data.get("body", ""),
|
| 340 |
)
|
| 341 |
|
| 342 |
+
log_usage(db, request.session_id, None, "analyze", analysis.token_usage.model_dump() if analysis.token_usage else None)
|
| 343 |
+
|
| 344 |
if analysis.extracted_variables:
|
| 345 |
set_context_variables(db, request.session_id, analysis.extracted_variables)
|
| 346 |
|
backend/app/api/routes/usage.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
from fastapi import APIRouter, Depends, Request
|
| 4 |
+
from sqlalchemy import func
|
| 5 |
+
from sqlalchemy.orm import Session
|
| 6 |
+
|
| 7 |
+
from backend import database
|
| 8 |
+
from backend.core.limiter import limiter
|
| 9 |
+
from backend.core.logging import get_logger
|
| 10 |
+
from backend.database import LLMUsage
|
| 11 |
+
|
| 12 |
+
router = APIRouter()
|
| 13 |
+
logger = get_logger(__name__)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
@router.get("/usage")
|
| 17 |
+
@limiter.limit("30/minute")
|
| 18 |
+
def get_usage(
|
| 19 |
+
request: Request,
|
| 20 |
+
session_id: Optional[str] = None,
|
| 21 |
+
user_id: Optional[str] = None,
|
| 22 |
+
db: Session = Depends(database.get_db),
|
| 23 |
+
):
|
| 24 |
+
base = db.query(LLMUsage)
|
| 25 |
+
if session_id:
|
| 26 |
+
base = base.filter(LLMUsage.session_id == session_id)
|
| 27 |
+
if user_id:
|
| 28 |
+
base = base.filter(LLMUsage.user_id == user_id)
|
| 29 |
+
|
| 30 |
+
breakdown_q = base.with_entities(
|
| 31 |
+
LLMUsage.call_type,
|
| 32 |
+
func.count().label("calls"),
|
| 33 |
+
func.sum(LLMUsage.prompt_tokens).label("prompt_tokens"),
|
| 34 |
+
func.sum(LLMUsage.completion_tokens).label("completion_tokens"),
|
| 35 |
+
func.sum(LLMUsage.total_tokens).label("total_tokens"),
|
| 36 |
+
).group_by(LLMUsage.call_type).all()
|
| 37 |
+
|
| 38 |
+
total_row = base.with_entities(
|
| 39 |
+
func.sum(LLMUsage.prompt_tokens),
|
| 40 |
+
func.sum(LLMUsage.completion_tokens),
|
| 41 |
+
func.sum(LLMUsage.total_tokens),
|
| 42 |
+
).first()
|
| 43 |
+
|
| 44 |
+
return {
|
| 45 |
+
"breakdown": [
|
| 46 |
+
{
|
| 47 |
+
"call_type": r.call_type,
|
| 48 |
+
"calls": r.calls,
|
| 49 |
+
"prompt_tokens": r.prompt_tokens or 0,
|
| 50 |
+
"completion_tokens": r.completion_tokens or 0,
|
| 51 |
+
"total_tokens": r.total_tokens or 0,
|
| 52 |
+
}
|
| 53 |
+
for r in breakdown_q
|
| 54 |
+
],
|
| 55 |
+
"totals": {
|
| 56 |
+
"prompt_tokens": total_row[0] or 0,
|
| 57 |
+
"completion_tokens": total_row[1] or 0,
|
| 58 |
+
"total_tokens": total_row[2] or 0,
|
| 59 |
+
},
|
| 60 |
+
}
|
backend/core/config.py
CHANGED
|
@@ -10,6 +10,13 @@ class Settings(BaseSettings):
|
|
| 10 |
HTTP_TIMEOUT: int = 120
|
| 11 |
RESPONSE_TRUNCATION_LIMIT: int = 4000
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Auth
|
| 14 |
AUTH_USERNAME: str = "admin"
|
| 15 |
AUTH_PASSWORD: str = "changeme"
|
|
|
|
| 10 |
HTTP_TIMEOUT: int = 120
|
| 11 |
RESPONSE_TRUNCATION_LIMIT: int = 4000
|
| 12 |
|
| 13 |
+
# LLM provider (Item 18)
|
| 14 |
+
LLM_MODEL: str = "mistral-large-latest"
|
| 15 |
+
LLM_FALLBACK_MODEL: str = "open-mistral-7b"
|
| 16 |
+
|
| 17 |
+
# Token budget cap per session β 0 = no limit (Item 17)
|
| 18 |
+
MAX_TOKENS_PER_SESSION: int = 0
|
| 19 |
+
|
| 20 |
# Auth
|
| 21 |
AUTH_USERNAME: str = "admin"
|
| 22 |
AUTH_PASSWORD: str = "changeme"
|
backend/database.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
-
from sqlalchemy import Column, DateTime, ForeignKey, Integer, JSON, String, Table, Text, Unicode, create_engine
|
| 9 |
from sqlalchemy.orm import declarative_base, relationship, sessionmaker
|
| 10 |
|
| 11 |
logger = logging.getLogger(__name__)
|
|
@@ -143,23 +143,25 @@ class ChatMessage(Base):
|
|
| 143 |
# Relationships
|
| 144 |
chat_session = relationship("ChatSession", back_populates="messages")
|
| 145 |
|
| 146 |
-
# Create tables if they don't exist
|
| 147 |
-
Base.metadata.create_all(bind=engine)
|
| 148 |
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
def get_db():
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
+
from sqlalchemy import Column, DateTime, ForeignKey, Integer, JSON, String, Table, Text, Unicode, create_engine
|
| 9 |
from sqlalchemy.orm import declarative_base, relationship, sessionmaker
|
| 10 |
|
| 11 |
logger = logging.getLogger(__name__)
|
|
|
|
| 143 |
# Relationships
|
| 144 |
chat_session = relationship("ChatSession", back_populates="messages")
|
| 145 |
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
class LLMUsage(Base):
|
| 148 |
+
"""Tracks token consumption per LLM call for cost monitoring and budget enforcement."""
|
| 149 |
+
__tablename__ = "llm_usage"
|
| 150 |
|
| 151 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 152 |
+
session_id = Column(String, nullable=True, index=True)
|
| 153 |
+
user_id = Column(String, nullable=True)
|
| 154 |
+
call_type = Column(String, nullable=False) # "plan" | "execute_step" | "analyze" | "chat"
|
| 155 |
+
prompt_tokens = Column(Integer, default=0)
|
| 156 |
+
completion_tokens = Column(Integer, default=0)
|
| 157 |
+
total_tokens = Column(Integer, default=0)
|
| 158 |
+
timestamp = Column(DateTime, default=datetime.utcnow)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# Create tables if they don't exist.
|
| 162 |
+
# For new deployments prefer: alembic upgrade head
|
| 163 |
+
# For existing deployments: alembic stamp a1b2c3d4e5f6 && alembic upgrade head
|
| 164 |
+
Base.metadata.create_all(bind=engine)
|
| 165 |
|
| 166 |
|
| 167 |
def get_db():
|
backend/integrations/llm/base.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class BaseLLMClient(ABC):
|
| 5 |
+
@abstractmethod
|
| 6 |
+
def invoke(self, messages) -> tuple[str, dict | None]:
|
| 7 |
+
"""Invoke the LLM. Returns (content_str, token_usage_or_None)."""
|
| 8 |
+
...
|
backend/integrations/llm/client.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
from langchain_mistralai.chat_models import ChatMistralAI
|
|
|
|
|
|
|
| 2 |
from backend.core.logging import get_logger
|
|
|
|
| 3 |
|
| 4 |
logger = get_logger(__name__)
|
| 5 |
|
| 6 |
-
_MODEL = "mistral-large-latest"
|
| 7 |
-
|
| 8 |
|
| 9 |
def _extract_usage(ai_msg) -> dict | None:
|
| 10 |
usage = ai_msg.response_metadata.get("token_usage", {})
|
|
@@ -17,18 +18,41 @@ def _extract_usage(ai_msg) -> dict | None:
|
|
| 17 |
}
|
| 18 |
|
| 19 |
|
| 20 |
-
class MistralClient:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def __init__(self, temperature: float = 0, timeout: int = 120):
|
| 24 |
-
self._llm = ChatMistralAI(model_name=_MODEL, temperature=temperature, timeout=timeout)
|
| 25 |
|
| 26 |
def invoke(self, messages) -> tuple[str, dict | None]:
|
| 27 |
-
"""Invoke the LLM. Returns (content_str, token_usage_or_None)."""
|
| 28 |
ai_msg = self._llm.invoke(messages)
|
| 29 |
return ai_msg.content, _extract_usage(ai_msg)
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# One instance per temperature setting β instantiated once per process, not per request.
|
| 33 |
-
deterministic =
|
| 34 |
-
chat =
|
|
|
|
| 1 |
from langchain_mistralai.chat_models import ChatMistralAI
|
| 2 |
+
|
| 3 |
+
from backend.core.config import settings
|
| 4 |
from backend.core.logging import get_logger
|
| 5 |
+
from .base import BaseLLMClient
|
| 6 |
|
| 7 |
logger = get_logger(__name__)
|
| 8 |
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def _extract_usage(ai_msg) -> dict | None:
|
| 11 |
usage = ai_msg.response_metadata.get("token_usage", {})
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
|
| 21 |
+
class MistralClient(BaseLLMClient):
|
| 22 |
+
def __init__(self, model: str, temperature: float = 0, timeout: int = 120):
|
| 23 |
+
self._llm = ChatMistralAI(model_name=model, temperature=temperature, timeout=timeout)
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def invoke(self, messages) -> tuple[str, dict | None]:
|
|
|
|
| 26 |
ai_msg = self._llm.invoke(messages)
|
| 27 |
return ai_msg.content, _extract_usage(ai_msg)
|
| 28 |
|
| 29 |
|
| 30 |
+
class FallbackLLMClient(BaseLLMClient):
|
| 31 |
+
"""Tries primary; on failure retries with fallback client if configured."""
|
| 32 |
+
|
| 33 |
+
def __init__(self, primary: BaseLLMClient, fallback: BaseLLMClient | None):
|
| 34 |
+
self._primary = primary
|
| 35 |
+
self._fallback = fallback
|
| 36 |
+
|
| 37 |
+
def invoke(self, messages) -> tuple[str, dict | None]:
|
| 38 |
+
try:
|
| 39 |
+
return self._primary.invoke(messages)
|
| 40 |
+
except Exception as err:
|
| 41 |
+
if self._fallback is None:
|
| 42 |
+
raise
|
| 43 |
+
logger.warning("Primary LLM failed (%s), retrying with fallback.", err)
|
| 44 |
+
return self._fallback.invoke(messages)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _build_client(temperature: float) -> BaseLLMClient:
|
| 48 |
+
primary = MistralClient(model=settings.LLM_MODEL, temperature=temperature)
|
| 49 |
+
fallback_model = settings.LLM_FALLBACK_MODEL
|
| 50 |
+
if fallback_model and fallback_model != settings.LLM_MODEL:
|
| 51 |
+
fallback = MistralClient(model=fallback_model, temperature=temperature)
|
| 52 |
+
return FallbackLLMClient(primary, fallback)
|
| 53 |
+
return FallbackLLMClient(primary, None)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
# One instance per temperature setting β instantiated once per process, not per request.
|
| 57 |
+
deterministic = _build_client(temperature=0)
|
| 58 |
+
chat = _build_client(temperature=0.2)
|
backend/main.py
CHANGED
|
@@ -14,7 +14,7 @@ from backend.core.config import settings
|
|
| 14 |
from backend.core.errors import AppError, app_error_handler
|
| 15 |
from backend.core.limiter import limiter
|
| 16 |
from backend.core.logging import get_logger
|
| 17 |
-
from backend.app.api.routes import specs, assets, sessions, history, chat, execution, auth
|
| 18 |
|
| 19 |
logger = get_logger(__name__)
|
| 20 |
|
|
@@ -22,9 +22,8 @@ logger = get_logger(__name__)
|
|
| 22 |
for category in ["audio", "video", "documents", "images", "specs"]:
|
| 23 |
os.makedirs(os.path.join(settings.UPLOAD_DIR, category), exist_ok=True)
|
| 24 |
|
| 25 |
-
# Create DB tables
|
| 26 |
database.Base.metadata.create_all(bind=database.engine)
|
| 27 |
-
database.run_migrations()
|
| 28 |
|
| 29 |
app = FastAPI(title="AI API Testing Assistant")
|
| 30 |
app.state.limiter = limiter
|
|
@@ -61,6 +60,7 @@ app.include_router(sessions.router, dependencies=_auth)
|
|
| 61 |
app.include_router(history.router, dependencies=_auth)
|
| 62 |
app.include_router(chat.router, dependencies=_auth)
|
| 63 |
app.include_router(execution.router, dependencies=_auth)
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
@app.get("/")
|
|
|
|
| 14 |
from backend.core.errors import AppError, app_error_handler
|
| 15 |
from backend.core.limiter import limiter
|
| 16 |
from backend.core.logging import get_logger
|
| 17 |
+
from backend.app.api.routes import specs, assets, sessions, history, chat, execution, auth, usage
|
| 18 |
|
| 19 |
logger = get_logger(__name__)
|
| 20 |
|
|
|
|
| 22 |
for category in ["audio", "video", "documents", "images", "specs"]:
|
| 23 |
os.makedirs(os.path.join(settings.UPLOAD_DIR, category), exist_ok=True)
|
| 24 |
|
| 25 |
+
# Create DB tables (idempotent). For schema migrations use: alembic upgrade head
|
| 26 |
database.Base.metadata.create_all(bind=database.engine)
|
|
|
|
| 27 |
|
| 28 |
app = FastAPI(title="AI API Testing Assistant")
|
| 29 |
app.state.limiter = limiter
|
|
|
|
| 60 |
app.include_router(history.router, dependencies=_auth)
|
| 61 |
app.include_router(chat.router, dependencies=_auth)
|
| 62 |
app.include_router(execution.router, dependencies=_auth)
|
| 63 |
+
app.include_router(usage.router, dependencies=_auth)
|
| 64 |
|
| 65 |
|
| 66 |
@app.get("/")
|
backend/services/asset_service.py
CHANGED
|
@@ -1,10 +1,42 @@
|
|
| 1 |
import os
|
| 2 |
import uuid
|
| 3 |
from typing import List, Optional, Dict, Any
|
|
|
|
|
|
|
| 4 |
from sqlalchemy.orm import Session
|
|
|
|
| 5 |
from ..database import Asset, Collection, SpecDocument
|
| 6 |
from .storage import LocalStorageProvider, SupabaseStorageProvider
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Load environment for storage configuration
|
| 9 |
SUPABASE_URL = os.getenv("SUPABASE_URL")
|
| 10 |
# Use Service Role Key for storage operations (bypass RLS)
|
|
@@ -52,11 +84,21 @@ class AssetService:
|
|
| 52 |
file_id = str(uuid.uuid4())
|
| 53 |
file_ext = os.path.splitext(file.filename)[1]
|
| 54 |
category = get_category(file.filename, file.content_type)
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Use provided folder or category as prefix
|
| 57 |
prefix = folder if folder else category
|
| 58 |
relative_path = f"{prefix}/{file_id}{file_ext}"
|
| 59 |
-
|
| 60 |
# Save to storage
|
| 61 |
storage.save(file.file, relative_path)
|
| 62 |
|
|
|
|
| 1 |
import os
|
| 2 |
import uuid
|
| 3 |
from typing import List, Optional, Dict, Any
|
| 4 |
+
|
| 5 |
+
import filetype
|
| 6 |
from sqlalchemy.orm import Session
|
| 7 |
+
|
| 8 |
from ..database import Asset, Collection, SpecDocument
|
| 9 |
from .storage import LocalStorageProvider, SupabaseStorageProvider
|
| 10 |
|
| 11 |
+
# MIME types allowed per category (used for magic-byte validation)
|
| 12 |
+
_ALLOWED_MIMES: dict[str, set[str]] = {
|
| 13 |
+
"audio": {"audio/mpeg", "audio/wav", "audio/ogg", "audio/aac", "audio/mp4", "audio/x-m4a"},
|
| 14 |
+
"video": {"video/mp4", "video/quicktime", "video/avi", "video/x-matroska", "video/webm"},
|
| 15 |
+
"images": {"image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml"},
|
| 16 |
+
"documents": {
|
| 17 |
+
"application/pdf", "application/msword",
|
| 18 |
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 19 |
+
"application/vnd.ms-excel",
|
| 20 |
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 21 |
+
"text/plain", "text/csv", "application/json", "application/zip",
|
| 22 |
+
},
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# Extensions accepted for text-based files that filetype cannot detect from bytes
|
| 26 |
+
_TEXT_EXTENSIONS = {".txt", ".json", ".yaml", ".yml", ".csv", ".md", ".xml", ".html", ".htm"}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _validate_magic(header: bytes, category: str, filename: str) -> tuple[bool, str]:
|
| 30 |
+
"""Returns (is_valid, detected_mime_or_reason)."""
|
| 31 |
+
kind = filetype.guess(header)
|
| 32 |
+
if kind is None:
|
| 33 |
+
ext = os.path.splitext(filename)[1].lower()
|
| 34 |
+
if category == "documents" and ext in _TEXT_EXTENSIONS:
|
| 35 |
+
return True, "text/plain"
|
| 36 |
+
return False, f"undetectable type (ext: {ext})"
|
| 37 |
+
mime = kind.mime
|
| 38 |
+
return mime in _ALLOWED_MIMES.get(category, set()), mime
|
| 39 |
+
|
| 40 |
# Load environment for storage configuration
|
| 41 |
SUPABASE_URL = os.getenv("SUPABASE_URL")
|
| 42 |
# Use Service Role Key for storage operations (bypass RLS)
|
|
|
|
| 84 |
file_id = str(uuid.uuid4())
|
| 85 |
file_ext = os.path.splitext(file.filename)[1]
|
| 86 |
category = get_category(file.filename, file.content_type)
|
| 87 |
+
|
| 88 |
+
# Magic-byte validation: read header, seek back, then save
|
| 89 |
+
header = file.file.read(1024)
|
| 90 |
+
file.file.seek(0)
|
| 91 |
+
is_valid, detected_mime = _validate_magic(header, category, file.filename)
|
| 92 |
+
if not is_valid:
|
| 93 |
+
raise ValueError(
|
| 94 |
+
f"File rejected: detected type '{detected_mime}' is not allowed "
|
| 95 |
+
f"for category '{category}'. Check the file is not corrupted or mislabeled."
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
# Use provided folder or category as prefix
|
| 99 |
prefix = folder if folder else category
|
| 100 |
relative_path = f"{prefix}/{file_id}{file_ext}"
|
| 101 |
+
|
| 102 |
# Save to storage
|
| 103 |
storage.save(file.file, relative_path)
|
| 104 |
|
backend/services/chat_assistant.py
CHANGED
|
@@ -141,7 +141,7 @@ def process_message(
|
|
| 141 |
messages.append(HumanMessage(content=message))
|
| 142 |
|
| 143 |
try:
|
| 144 |
-
content,
|
| 145 |
raw = content.strip()
|
| 146 |
|
| 147 |
# Strip markdown code fences if present
|
|
@@ -156,6 +156,7 @@ def process_message(
|
|
| 156 |
if "message" not in parsed:
|
| 157 |
parsed["message"] = raw
|
| 158 |
|
|
|
|
| 159 |
return parsed
|
| 160 |
|
| 161 |
except Exception as e:
|
|
@@ -163,5 +164,6 @@ def process_message(
|
|
| 163 |
return {
|
| 164 |
"action": "reply",
|
| 165 |
"message": "I encountered an error processing your request. Please try again.",
|
| 166 |
-
"explanation": str(e)
|
|
|
|
| 167 |
}
|
|
|
|
| 141 |
messages.append(HumanMessage(content=message))
|
| 142 |
|
| 143 |
try:
|
| 144 |
+
content, token_usage = _llm.invoke(messages)
|
| 145 |
raw = content.strip()
|
| 146 |
|
| 147 |
# Strip markdown code fences if present
|
|
|
|
| 156 |
if "message" not in parsed:
|
| 157 |
parsed["message"] = raw
|
| 158 |
|
| 159 |
+
parsed["_token_usage"] = token_usage
|
| 160 |
return parsed
|
| 161 |
|
| 162 |
except Exception as e:
|
|
|
|
| 164 |
return {
|
| 165 |
"action": "reply",
|
| 166 |
"message": "I encountered an error processing your request. Please try again.",
|
| 167 |
+
"explanation": str(e),
|
| 168 |
+
"_token_usage": None,
|
| 169 |
}
|
backend/services/usage_service.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sqlalchemy.orm import Session
|
| 2 |
+
from sqlalchemy import func
|
| 3 |
+
from backend.database import LLMUsage
|
| 4 |
+
from backend.core.config import settings
|
| 5 |
+
from backend.core.errors import AppError
|
| 6 |
+
from backend.core.logging import get_logger
|
| 7 |
+
|
| 8 |
+
logger = get_logger(__name__)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def log_usage(
|
| 12 |
+
db: Session,
|
| 13 |
+
session_id: str | None,
|
| 14 |
+
user_id: str | None,
|
| 15 |
+
call_type: str,
|
| 16 |
+
token_usage: dict | None,
|
| 17 |
+
) -> None:
|
| 18 |
+
if not token_usage:
|
| 19 |
+
return
|
| 20 |
+
entry = LLMUsage(
|
| 21 |
+
session_id=session_id,
|
| 22 |
+
user_id=user_id,
|
| 23 |
+
call_type=call_type,
|
| 24 |
+
prompt_tokens=token_usage.get("prompt_tokens", 0),
|
| 25 |
+
completion_tokens=token_usage.get("completion_tokens", 0),
|
| 26 |
+
total_tokens=token_usage.get("total_tokens", 0),
|
| 27 |
+
)
|
| 28 |
+
db.add(entry)
|
| 29 |
+
db.commit()
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_session_total_tokens(db: Session, session_id: str) -> int:
|
| 33 |
+
result = (
|
| 34 |
+
db.query(func.sum(LLMUsage.total_tokens))
|
| 35 |
+
.filter(LLMUsage.session_id == session_id)
|
| 36 |
+
.scalar()
|
| 37 |
+
)
|
| 38 |
+
return result or 0
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def check_budget(db: Session, session_id: str | None) -> None:
|
| 42 |
+
"""Raise AppError(429) if session has exceeded MAX_TOKENS_PER_SESSION."""
|
| 43 |
+
cap = settings.MAX_TOKENS_PER_SESSION
|
| 44 |
+
if not cap or not session_id:
|
| 45 |
+
return
|
| 46 |
+
used = get_session_total_tokens(db, session_id)
|
| 47 |
+
if used >= cap:
|
| 48 |
+
raise AppError(429, f"Session token budget exceeded: {used:,}/{cap:,} tokens used.")
|
frontend-react/index.html
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<title>
|
|
|
|
|
|
|
|
|
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
<div id="root"></div>
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en" data-theme="dark">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
+
<title>API Testing Assistant</title>
|
| 8 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 9 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 10 |
+
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet">
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
<div id="root"></div>
|
frontend-react/src/App.jsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
import React, { useState,
|
|
|
|
| 2 |
import {
|
| 3 |
Settings, History,
|
| 4 |
-
ChevronRight, ChevronLeft,
|
| 5 |
-
User, Layers, FolderOpen,
|
| 6 |
-
|
| 7 |
-
Sun, Moon, Database,
|
| 8 |
} from 'lucide-react';
|
| 9 |
import { AppProvider, useAppContext } from './components/AppContext';
|
| 10 |
import CollectionsPage from './components/CollectionsPage';
|
|
@@ -15,10 +15,10 @@ import SettingsPage from './components/SettingsPage';
|
|
| 15 |
import ChatAssistant from './components/ChatAssistant';
|
| 16 |
import { ToastContainer } from './components/Toast';
|
| 17 |
import ErrorBoundary from './components/ErrorBoundary';
|
| 18 |
-
import { SpecService, SessionService, PlanService, AuthService } from './services/api';
|
| 19 |
import LoginPage from './components/LoginPage';
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
/* ββ Workflow icon (Activity-like) βββββββββββββββββββββββββββ */
|
| 22 |
const WorkflowIcon = ({ size = 15, className = '' }) => (
|
| 23 |
<svg width={size} height={size} viewBox="0 0 24 24" fill="none"
|
| 24 |
stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round"
|
|
@@ -30,210 +30,35 @@ const WorkflowIcon = ({ size = 15, className = '' }) => (
|
|
| 30 |
);
|
| 31 |
|
| 32 |
function MainApp() {
|
| 33 |
-
const {
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
isLoading, fetchCollections,
|
| 37 |
-
storedCredentials, setStoredCredentials, saveProfile, parsedSpec,
|
| 38 |
-
sessionContextVars, refreshSessionContext, sessionId,
|
| 39 |
-
executionPlan, setExecutionPlan,
|
| 40 |
-
scenario, setScenario,
|
| 41 |
-
startNewSession,
|
| 42 |
-
toasts, addToast, removeToast,
|
| 43 |
-
} = useAppContext();
|
| 44 |
|
| 45 |
-
const [activePage, setActivePage] = useState('workflow');
|
| 46 |
const [theme, setTheme] = useState('dark');
|
| 47 |
const [collapsed, setCollapsed] = useState(false);
|
| 48 |
-
const [rightPanelOpen, setRightPanelOpen] = useState(true);
|
| 49 |
-
const [rightPanelMode, setRightPanelMode] = useState('context');
|
| 50 |
|
| 51 |
-
/* Apply theme to <html data-theme="..."> */
|
| 52 |
useEffect(() => {
|
| 53 |
document.documentElement.setAttribute('data-theme', theme);
|
| 54 |
}, [theme]);
|
| 55 |
|
| 56 |
-
/* External nav events */
|
| 57 |
useEffect(() => {
|
| 58 |
-
const handle = (e) =>
|
| 59 |
window.addEventListener('nav-change', handle);
|
| 60 |
return () => window.removeEventListener('nav-change', handle);
|
| 61 |
-
}, []);
|
| 62 |
-
|
| 63 |
-
const [isPlanning, setIsPlanning] = useState(false);
|
| 64 |
-
const [executingStep, setExecutingStep] = useState(null);
|
| 65 |
-
const [isRunningAll, setIsRunningAll] = useState(false);
|
| 66 |
-
const [stepResults, setStepResults] = useState({});
|
| 67 |
-
const [otpPrompt, setOtpPrompt] = useState(null);
|
| 68 |
-
const [otpInput, setOtpInput] = useState('');
|
| 69 |
-
const [selectionPrompt, setSelectionPrompt] = useState(null);
|
| 70 |
-
const [planTokenUsage, setPlanTokenUsage] = useState(null);
|
| 71 |
-
const [totalScenarioTokens, setTotalScenarioTokens] = useState({ prompt: 0, completion: 0, total: 0 });
|
| 72 |
-
|
| 73 |
-
/* ββ Plan generation βββββββββββββββββββββββββββββββββββββββ */
|
| 74 |
-
const handleGeneratePlan = async () => {
|
| 75 |
-
if (!activeSpecId) { addToast('warning', 'Please select a collection first.'); return; }
|
| 76 |
-
if (!activeBaseUrl) { addToast('warning', 'Please set a Base URL for this collection.'); return; }
|
| 77 |
-
if (!scenario.trim()) { addToast('warning', 'Please describe a test scenario.'); return; }
|
| 78 |
-
|
| 79 |
-
setIsPlanning(true);
|
| 80 |
-
setPlanTokenUsage(null);
|
| 81 |
-
setStepResults({});
|
| 82 |
-
setTotalScenarioTokens({ prompt: 0, completion: 0, total: 0 });
|
| 83 |
-
|
| 84 |
-
try {
|
| 85 |
-
const newSid = await startNewSession();
|
| 86 |
-
if (!newSid) throw new Error('Could not initialize fresh session');
|
| 87 |
-
|
| 88 |
-
const payload = {
|
| 89 |
-
spec_content: typeof parsedSpec === 'string' ? parsedSpec : JSON.stringify(parsedSpec),
|
| 90 |
-
base_url: activeBaseUrl,
|
| 91 |
-
scenario,
|
| 92 |
-
user_credentials: storedCredentials,
|
| 93 |
-
spec_id: activeSpecId,
|
| 94 |
-
session_id: newSid,
|
| 95 |
-
};
|
| 96 |
-
const data = await PlanService.generatePlan(payload);
|
| 97 |
-
setExecutionPlan(data.execution_plan || []);
|
| 98 |
-
setPlanTokenUsage(data.token_usage);
|
| 99 |
-
|
| 100 |
-
if (data.suggested_credentials && Object.keys(data.suggested_credentials).length > 0) {
|
| 101 |
-
setStoredCredentials(prev => ({ ...prev, ...data.suggested_credentials }));
|
| 102 |
-
}
|
| 103 |
-
if (data.token_usage) {
|
| 104 |
-
setTotalScenarioTokens({
|
| 105 |
-
prompt: data.token_usage.prompt_tokens,
|
| 106 |
-
completion: data.token_usage.completion_tokens,
|
| 107 |
-
total: data.token_usage.total_tokens,
|
| 108 |
-
});
|
| 109 |
-
}
|
| 110 |
-
setStepResults({});
|
| 111 |
-
} catch (err) {
|
| 112 |
-
addToast('error', err.message || 'Plan generation failed.');
|
| 113 |
-
} finally {
|
| 114 |
-
setIsPlanning(false);
|
| 115 |
-
}
|
| 116 |
-
};
|
| 117 |
-
|
| 118 |
-
/* ββ Step execution ββββββββββββββββββββββββββββββββββββββββ */
|
| 119 |
-
const executeStep = async (stepDef) => {
|
| 120 |
-
setExecutingStep(stepDef.step);
|
| 121 |
-
try {
|
| 122 |
-
if (!sessionId) { addToast('error', 'Session not initialized. Please refresh.'); return; }
|
| 123 |
-
if (!activeBaseUrl) { addToast('warning', 'Base URL is missing.'); return; }
|
| 124 |
-
|
| 125 |
-
await refreshSessionContext();
|
| 126 |
-
const payload = {
|
| 127 |
-
session_id: sessionId,
|
| 128 |
-
step_definition: stepDef,
|
| 129 |
-
context_variables: sessionContextVars || {},
|
| 130 |
-
user_credentials: storedCredentials || {},
|
| 131 |
-
base_url: activeBaseUrl,
|
| 132 |
-
spec_id: activeSpecId,
|
| 133 |
-
};
|
| 134 |
-
const execData = await PlanService.executeStep(payload);
|
| 135 |
-
|
| 136 |
-
setStepResults(prev => ({
|
| 137 |
-
...prev,
|
| 138 |
-
[stepDef.step]: {
|
| 139 |
-
request: execData.executed_request,
|
| 140 |
-
response: execData.response,
|
| 141 |
-
analysis: { status: 'pending', response_summary: 'Analyzing response with AIβ¦' },
|
| 142 |
-
token_usage: execData.token_usage || { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
|
| 143 |
-
},
|
| 144 |
-
}));
|
| 145 |
-
|
| 146 |
-
const analyzePayload = {
|
| 147 |
-
session_id: sessionId,
|
| 148 |
-
step: stepDef.step,
|
| 149 |
-
response_data: execData.response,
|
| 150 |
-
step_definition: stepDef,
|
| 151 |
-
};
|
| 152 |
-
const analyzeData = await PlanService.analyzeResponse(analyzePayload);
|
| 153 |
-
|
| 154 |
-
const stepTokens = {
|
| 155 |
-
prompt_tokens: (execData.token_usage?.prompt_tokens || 0) + (analyzeData.token_usage?.prompt_tokens || 0),
|
| 156 |
-
completion_tokens: (execData.token_usage?.completion_tokens || 0) + (analyzeData.token_usage?.completion_tokens || 0),
|
| 157 |
-
total_tokens: (execData.token_usage?.total_tokens || 0) + (analyzeData.token_usage?.total_tokens || 0),
|
| 158 |
-
};
|
| 159 |
-
|
| 160 |
-
setStepResults(prev => ({
|
| 161 |
-
...prev,
|
| 162 |
-
[stepDef.step]: { ...prev[stepDef.step], analysis: analyzeData, token_usage: stepTokens },
|
| 163 |
-
}));
|
| 164 |
-
|
| 165 |
-
setTotalScenarioTokens(prev => ({
|
| 166 |
-
prompt: prev.prompt + stepTokens.prompt_tokens,
|
| 167 |
-
completion: prev.completion + stepTokens.completion_tokens,
|
| 168 |
-
total: prev.total + stepTokens.total_tokens,
|
| 169 |
-
}));
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
if (analyzeData.is_otp_required) {
|
| 174 |
-
setOtpPrompt({ stepDef, otpFieldName: analyzeData.otp_field_name || 'otp' });
|
| 175 |
-
}
|
| 176 |
-
if (analyzeData.is_selection_required && analyzeData.selection_options?.length > 0) {
|
| 177 |
-
setSelectionPrompt({
|
| 178 |
-
stepDef,
|
| 179 |
-
fieldName: analyzeData.selection_field_name || 'selected_item',
|
| 180 |
-
options: analyzeData.selection_options,
|
| 181 |
-
responseBody: execData.response.body,
|
| 182 |
-
});
|
| 183 |
-
}
|
| 184 |
-
} catch (err) {
|
| 185 |
-
console.error(`Execution failed for step ${stepDef.step}`, err);
|
| 186 |
-
} finally {
|
| 187 |
-
setExecutingStep(null);
|
| 188 |
-
}
|
| 189 |
-
};
|
| 190 |
-
|
| 191 |
-
const runAllSteps = async () => {
|
| 192 |
-
if (!executionPlan?.length) return;
|
| 193 |
-
setIsRunningAll(true);
|
| 194 |
-
for (const step of executionPlan) {
|
| 195 |
-
if (otpPrompt || selectionPrompt) break;
|
| 196 |
-
await executeStep(step);
|
| 197 |
-
}
|
| 198 |
-
setIsRunningAll(false);
|
| 199 |
-
};
|
| 200 |
-
|
| 201 |
-
const handleOtpSubmit = async () => {
|
| 202 |
-
if (!otpInput.trim()) return;
|
| 203 |
-
const { stepDef, otpFieldName } = otpPrompt;
|
| 204 |
-
try {
|
| 205 |
-
await saveProfile({ extra: { [otpFieldName]: otpInput } });
|
| 206 |
-
setOtpPrompt(null);
|
| 207 |
-
setOtpInput('');
|
| 208 |
-
await refreshSessionContext();
|
| 209 |
-
addToast('success', `OTP "${otpInput}" saved as "${otpFieldName}".`);
|
| 210 |
-
} catch (err) {
|
| 211 |
-
addToast('error', 'Failed to save OTP.');
|
| 212 |
-
}
|
| 213 |
-
};
|
| 214 |
-
|
| 215 |
-
const handleSelectionSubmit = async (option) => {
|
| 216 |
-
if (!selectionPrompt) return;
|
| 217 |
-
try {
|
| 218 |
-
await SessionService.updateContext(sessionId, selectionPrompt.fieldName, option.value);
|
| 219 |
-
setSelectionPrompt(null);
|
| 220 |
-
await refreshSessionContext();
|
| 221 |
-
} catch (err) {
|
| 222 |
-
addToast('error', 'Failed to save selection.');
|
| 223 |
-
}
|
| 224 |
-
};
|
| 225 |
-
|
| 226 |
-
/* ββ Nav structure βββββββββββββββββββββββββββββββββββββββββ */
|
| 227 |
const NAV1 = [
|
| 228 |
{ id: 'workflow', label: 'Workflow', Icon: WorkflowIcon, kbd: '1' },
|
| 229 |
{ id: 'collections', label: 'Collections', Icon: Layers, kbd: '2' },
|
| 230 |
{ id: 'profile', label: 'Profile', Icon: User, kbd: '3' },
|
| 231 |
];
|
| 232 |
const NAV2 = [
|
| 233 |
-
{ id: 'history', label: 'History', Icon: History,
|
| 234 |
{ id: 'media', label: 'Media hub', Icon: FolderOpen, kbd: '5' },
|
| 235 |
-
{ id: 'chat', label: 'Assistant', Icon: Bot,
|
| 236 |
-
{ id: 'settings', label: 'Settings', Icon: Settings,
|
| 237 |
];
|
| 238 |
|
| 239 |
return (
|
|
@@ -255,9 +80,7 @@ function MainApp() {
|
|
| 255 |
onClick={() => setCollapsed(c => !c)}
|
| 256 |
title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
| 257 |
>
|
| 258 |
-
{collapsed
|
| 259 |
-
? <ChevronRight size={13}/>
|
| 260 |
-
: <ChevronLeft size={13}/>}
|
| 261 |
</button>
|
| 262 |
</div>
|
| 263 |
|
|
@@ -267,7 +90,7 @@ function MainApp() {
|
|
| 267 |
<button
|
| 268 |
key={n.id}
|
| 269 |
className={`sb-item${activePage === n.id ? ' active' : ''}`}
|
| 270 |
-
onClick={() =>
|
| 271 |
title={collapsed ? n.label : undefined}
|
| 272 |
>
|
| 273 |
<n.Icon size={15} className="ico"/>
|
|
@@ -283,7 +106,7 @@ function MainApp() {
|
|
| 283 |
<button
|
| 284 |
key={n.id}
|
| 285 |
className={`sb-item${activePage === n.id ? ' active' : ''}`}
|
| 286 |
-
onClick={() =>
|
| 287 |
title={collapsed ? n.label : undefined}
|
| 288 |
>
|
| 289 |
<n.Icon size={15} className="ico"/>
|
|
@@ -295,7 +118,7 @@ function MainApp() {
|
|
| 295 |
|
| 296 |
<div className="sb-foot">
|
| 297 |
<span className="dot"/>
|
| 298 |
-
{!collapsed && <><span>session live</span><span style={{flex:1}}/></>}
|
| 299 |
</div>
|
| 300 |
</aside>
|
| 301 |
|
|
@@ -316,42 +139,6 @@ function MainApp() {
|
|
| 316 |
|
| 317 |
<div className="spacer"/>
|
| 318 |
|
| 319 |
-
{/* Token counters (workflow page only) */}
|
| 320 |
-
{activePage === 'workflow' && (planTokenUsage || totalScenarioTokens.total > 0) && (
|
| 321 |
-
<div style={{display:'flex',alignItems:'center',gap:6}}>
|
| 322 |
-
{planTokenUsage && (
|
| 323 |
-
<span className="tokstrip">
|
| 324 |
-
<span className="dot"/>plan <b>{planTokenUsage.total_tokens}</b>
|
| 325 |
-
</span>
|
| 326 |
-
)}
|
| 327 |
-
{totalScenarioTokens.total > 0 && (
|
| 328 |
-
<span className="tokstrip">
|
| 329 |
-
<span className="dot" style={{background:'var(--ok)'}}/>
|
| 330 |
-
total <b>{totalScenarioTokens.total}</b>
|
| 331 |
-
</span>
|
| 332 |
-
)}
|
| 333 |
-
</div>
|
| 334 |
-
)}
|
| 335 |
-
|
| 336 |
-
{/* Base URL input (workflow + spec selected) */}
|
| 337 |
-
{activePage === 'workflow' && activeSpecId && (
|
| 338 |
-
<div className="url-input">
|
| 339 |
-
<span className="label">base</span>
|
| 340 |
-
<input
|
| 341 |
-
value={activeBaseUrl || ''}
|
| 342 |
-
onChange={e => setActiveBaseUrl(e.target.value)}
|
| 343 |
-
onBlur={async () => {
|
| 344 |
-
if (activeBaseUrl) {
|
| 345 |
-
try { await SpecService.updateBaseUrl(activeSpecId, activeBaseUrl); }
|
| 346 |
-
catch (e) { console.error('URL save failed', e); }
|
| 347 |
-
}
|
| 348 |
-
}}
|
| 349 |
-
placeholder="https://api.example.com"
|
| 350 |
-
spellCheck={false}
|
| 351 |
-
/>
|
| 352 |
-
</div>
|
| 353 |
-
)}
|
| 354 |
-
|
| 355 |
{/* Theme toggle */}
|
| 356 |
<div className="theme-toggle">
|
| 357 |
<button
|
|
@@ -371,564 +158,32 @@ function MainApp() {
|
|
| 371 |
</div>
|
| 372 |
</header>
|
| 373 |
|
| 374 |
-
{/* ββ Page
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
<
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
</p>
|
| 399 |
-
{!activeSpecId && (
|
| 400 |
-
<button
|
| 401 |
-
onClick={() => setActivePage('collections')}
|
| 402 |
-
className="btn"
|
| 403 |
-
style={{marginTop:24,gap:8}}
|
| 404 |
-
>
|
| 405 |
-
<Layers size={13}/> Browse Collections
|
| 406 |
-
</button>
|
| 407 |
-
)}
|
| 408 |
-
</div>
|
| 409 |
-
) : (
|
| 410 |
-
/* ββ Execution plan ββ */
|
| 411 |
-
<div>
|
| 412 |
-
{/* Plan header */}
|
| 413 |
-
<div className="plan-meta">
|
| 414 |
-
<div>
|
| 415 |
-
<div className="h-eyebrow">Execution plan</div>
|
| 416 |
-
<div style={{display:'flex',alignItems:'baseline',gap:10,marginTop:2}}>
|
| 417 |
-
<span style={{fontSize:15,fontWeight:600,color:'var(--fg-0)'}}>{executionPlan.length} steps</span>
|
| 418 |
-
</div>
|
| 419 |
-
</div>
|
| 420 |
-
<div className="grow"/>
|
| 421 |
-
<div style={{display:'flex',alignItems:'center',gap:6,fontSize:12,color:'var(--fg-2)'}}>
|
| 422 |
-
<span style={{width:6,height:6,borderRadius:'50%',background:'var(--ok)',display:'inline-block'}}/>
|
| 423 |
-
{Object.values(stepResults).filter(r => r.analysis?.status === 'success').length}
|
| 424 |
-
<span style={{color:'var(--fg-3)'}}>/ {executionPlan.length} ok</span>
|
| 425 |
-
</div>
|
| 426 |
-
<div className="progress">
|
| 427 |
-
<i style={{width: `${Math.round((Object.values(stepResults).filter(r => r.analysis?.status === 'success').length / executionPlan.length) * 100)}%`}}/>
|
| 428 |
-
</div>
|
| 429 |
-
<button className="btn" onClick={() => { setExecutionPlan(null); setStepResults({}); }}>
|
| 430 |
-
<RefreshCw size={13}/> Reset
|
| 431 |
-
</button>
|
| 432 |
-
<button
|
| 433 |
-
className="btn btn-primary"
|
| 434 |
-
onClick={runAllSteps}
|
| 435 |
-
disabled={isRunningAll || !!executingStep}
|
| 436 |
-
style={{gap:6}}
|
| 437 |
-
>
|
| 438 |
-
{isRunningAll
|
| 439 |
-
? <><RefreshCw size={13} style={{animation:'spin 1s linear infinite'}}/> Runningβ¦</>
|
| 440 |
-
: <><Zap size={13}/> Run all</>}
|
| 441 |
-
</button>
|
| 442 |
-
</div>
|
| 443 |
-
|
| 444 |
-
{/* Steps */}
|
| 445 |
-
{executionPlan.map(step => {
|
| 446 |
-
const isRunning = executingStep === step.step;
|
| 447 |
-
const res = stepResults[step.step];
|
| 448 |
-
const status = res?.analysis?.status;
|
| 449 |
-
const stateClass = status === 'success' ? ' is-ok' : status === 'failed' ? ' is-err' : isRunning ? ' is-running' : '';
|
| 450 |
-
|
| 451 |
-
return (
|
| 452 |
-
<div key={step.step} className={`step${stateClass}`}>
|
| 453 |
-
<div className="step-row">
|
| 454 |
-
{/* Step number / status indicator */}
|
| 455 |
-
<div className="step-num">
|
| 456 |
-
{status === 'success' ? <CheckCircle2 size={14}/>
|
| 457 |
-
: status === 'failed' ? <AlertCircle size={14}/>
|
| 458 |
-
: isRunning ? <RefreshCw size={13} style={{animation:'spin 1s linear infinite'}}/>
|
| 459 |
-
: step.step}
|
| 460 |
-
</div>
|
| 461 |
-
|
| 462 |
-
<div className="step-main">
|
| 463 |
-
<div className="step-title">
|
| 464 |
-
<span className={`method m-${step.method}`}>{step.method}</span>
|
| 465 |
-
<span className="endpoint">
|
| 466 |
-
<span className="path">{step.endpoint}</span>
|
| 467 |
-
</span>
|
| 468 |
-
{isRunning && <span className="pill pill-acc">running</span>}
|
| 469 |
-
</div>
|
| 470 |
-
<div className="step-purpose">{step.purpose}</div>
|
| 471 |
-
</div>
|
| 472 |
-
|
| 473 |
-
<div className="step-actions">
|
| 474 |
-
{res?.token_usage && (
|
| 475 |
-
<span className="tokstrip"><b>{res.token_usage.total_tokens.toLocaleString()}</b> tok</span>
|
| 476 |
-
)}
|
| 477 |
-
{res?.response?.status_code !== undefined && (
|
| 478 |
-
<span className={`pill ${res.response.status_code >= 200 && res.response.status_code < 300 ? 'pill-ok' : res.response.status_code >= 400 ? 'pill-err' : 'pill-warn'}`}>
|
| 479 |
-
{res.response.status_code}
|
| 480 |
-
</span>
|
| 481 |
-
)}
|
| 482 |
-
{status === 'failed' && (
|
| 483 |
-
<button
|
| 484 |
-
onClick={() => executeStep(step)}
|
| 485 |
-
disabled={isRunning || isRunningAll}
|
| 486 |
-
className="btn"
|
| 487 |
-
style={{color:'var(--warn)',borderColor:'var(--warn-soft)'}}
|
| 488 |
-
>
|
| 489 |
-
<RefreshCw size={12}/> Retry
|
| 490 |
-
</button>
|
| 491 |
-
)}
|
| 492 |
-
<button
|
| 493 |
-
onClick={() => executeStep(step)}
|
| 494 |
-
disabled={isRunning || isRunningAll}
|
| 495 |
-
className="btn btn-primary"
|
| 496 |
-
>
|
| 497 |
-
{isRunning
|
| 498 |
-
? <><RefreshCw size={12} style={{animation:'spin 1s linear infinite'}}/> Running</>
|
| 499 |
-
: <><Zap size={12}/> Execute</>}
|
| 500 |
-
</button>
|
| 501 |
-
</div>
|
| 502 |
-
</div>
|
| 503 |
-
|
| 504 |
-
{/* Step result body */}
|
| 505 |
-
{res && (
|
| 506 |
-
<div className="step-body">
|
| 507 |
-
{/* AI analysis */}
|
| 508 |
-
<div className="step-analysis">
|
| 509 |
-
<span className="tag">analysis</span>
|
| 510 |
-
<div className="body">
|
| 511 |
-
{res.analysis.response_summary || (status === 'success' ? 'Step completed successfully.' : status === 'failed' ? 'Step encountered an error.' : 'Analyzingβ¦')}
|
| 512 |
-
{res.analysis.extracted_variables && Object.keys(res.analysis.extracted_variables).length > 0 && (
|
| 513 |
-
<div className="vars">
|
| 514 |
-
{Object.entries(res.analysis.extracted_variables).map(([k, v]) => (
|
| 515 |
-
<span className="var" key={k}>
|
| 516 |
-
<span className="k">{k}</span>
|
| 517 |
-
<span className="eq">=</span>
|
| 518 |
-
<span className="v">{String(v).slice(0, 60)}</span>
|
| 519 |
-
</span>
|
| 520 |
-
))}
|
| 521 |
-
</div>
|
| 522 |
-
)}
|
| 523 |
-
</div>
|
| 524 |
-
</div>
|
| 525 |
-
|
| 526 |
-
{/* Request / Response */}
|
| 527 |
-
<div className="reqres">
|
| 528 |
-
<div>
|
| 529 |
-
<div className="rr-head">
|
| 530 |
-
<span className="lbl">Request</span>
|
| 531 |
-
</div>
|
| 532 |
-
{!res.request ? (
|
| 533 |
-
<div style={{fontSize:11,color:'var(--fg-3)',fontStyle:'italic'}}>Preparingβ¦</div>
|
| 534 |
-
) : (
|
| 535 |
-
<div style={{fontSize:11.5}}>
|
| 536 |
-
<div className="kv-block" style={{marginBottom:8}}>
|
| 537 |
-
<div className="kv-row">
|
| 538 |
-
<span className="k">URL</span>
|
| 539 |
-
<span className="v">{res.request.url}</span>
|
| 540 |
-
</div>
|
| 541 |
-
</div>
|
| 542 |
-
{res.request.headers && Object.keys(res.request.headers).length > 0 && (
|
| 543 |
-
<>
|
| 544 |
-
<span className="kv-label">Headers</span>
|
| 545 |
-
<div className="kv-block" style={{marginBottom:8}}>
|
| 546 |
-
{Object.entries(res.request.headers).map(([k, v]) => (
|
| 547 |
-
<div className="kv-row" key={k}>
|
| 548 |
-
<span className="k">{k}:</span>
|
| 549 |
-
<span className="v">{v}</span>
|
| 550 |
-
</div>
|
| 551 |
-
))}
|
| 552 |
-
</div>
|
| 553 |
-
</>
|
| 554 |
-
)}
|
| 555 |
-
{res.request.query_params && Object.keys(res.request.query_params).length > 0 && (
|
| 556 |
-
<>
|
| 557 |
-
<span className="kv-label">Query</span>
|
| 558 |
-
<div className="kv-block" style={{marginBottom:8}}>
|
| 559 |
-
{Object.entries(res.request.query_params).map(([k, v]) => (
|
| 560 |
-
<div className="kv-row" key={k}>
|
| 561 |
-
<span className="k">{k}=</span>
|
| 562 |
-
<span className="v">{v}</span>
|
| 563 |
-
</div>
|
| 564 |
-
))}
|
| 565 |
-
</div>
|
| 566 |
-
</>
|
| 567 |
-
)}
|
| 568 |
-
{res.request.body != null && (
|
| 569 |
-
<>
|
| 570 |
-
<span className="kv-label">Body</span>
|
| 571 |
-
<pre className="code">{
|
| 572 |
-
typeof res.request.body === 'string'
|
| 573 |
-
? (() => { try { return JSON.stringify(JSON.parse(res.request.body), null, 2); } catch { return res.request.body; } })()
|
| 574 |
-
: JSON.stringify(res.request.body, null, 2)
|
| 575 |
-
}</pre>
|
| 576 |
-
</>
|
| 577 |
-
)}
|
| 578 |
-
{res.request.form_data && Object.keys(res.request.form_data).length > 0 && (
|
| 579 |
-
<>
|
| 580 |
-
<span className="kv-label">Form data</span>
|
| 581 |
-
<pre className="code">{JSON.stringify(res.request.form_data, null, 2)}</pre>
|
| 582 |
-
</>
|
| 583 |
-
)}
|
| 584 |
-
</div>
|
| 585 |
-
)}
|
| 586 |
-
</div>
|
| 587 |
-
|
| 588 |
-
<div>
|
| 589 |
-
<div className="rr-head">
|
| 590 |
-
<span className="lbl">Response</span>
|
| 591 |
-
</div>
|
| 592 |
-
{!res.response ? (
|
| 593 |
-
<div style={{fontSize:11,color:'var(--fg-3)',fontStyle:'italic'}}>Waitingβ¦</div>
|
| 594 |
-
) : (
|
| 595 |
-
<pre className="code">{
|
| 596 |
-
(() => {
|
| 597 |
-
const body = res.response.body;
|
| 598 |
-
if (body == null || body === '') return '(empty)';
|
| 599 |
-
if (typeof body === 'object') {
|
| 600 |
-
try { return JSON.stringify(body, null, 2); } catch { return String(body); }
|
| 601 |
-
}
|
| 602 |
-
try { return JSON.stringify(JSON.parse(body), null, 2); } catch { return String(body); }
|
| 603 |
-
})()
|
| 604 |
-
}</pre>
|
| 605 |
-
)}
|
| 606 |
-
</div>
|
| 607 |
-
</div>
|
| 608 |
-
</div>
|
| 609 |
-
)}
|
| 610 |
-
</div>
|
| 611 |
-
);
|
| 612 |
-
})}
|
| 613 |
-
</div>
|
| 614 |
-
)}
|
| 615 |
-
|
| 616 |
-
{/* OTP modal */}
|
| 617 |
-
{otpPrompt && (
|
| 618 |
-
<div style={{position:'fixed',inset:0,zIndex:50,display:'flex',alignItems:'center',justifyContent:'center',background:'rgba(0,0,0,0.7)',backdropFilter:'blur(8px)',padding:16}}>
|
| 619 |
-
<div style={{background:'var(--bg-1)',border:'1px solid var(--line-3)',borderRadius:10,width:'100%',maxWidth:420,overflow:'hidden',boxShadow:'var(--shadow-md)'}}>
|
| 620 |
-
<div style={{padding:'12px 16px',borderBottom:'1px solid var(--line-1)',display:'flex',alignItems:'center',justifyContent:'space-between'}}>
|
| 621 |
-
<div style={{display:'flex',alignItems:'center',gap:8}}>
|
| 622 |
-
<Zap size={14} style={{color:'var(--accent)'}}/>
|
| 623 |
-
<span style={{fontSize:13,fontWeight:600,color:'var(--fg-0)'}}>Verification Required</span>
|
| 624 |
-
</div>
|
| 625 |
-
<button onClick={() => setOtpPrompt(null)} className="ico-btn"><X size={14}/></button>
|
| 626 |
-
</div>
|
| 627 |
-
<div style={{padding:20}}>
|
| 628 |
-
<p style={{fontSize:12,color:'var(--fg-2)',marginBottom:14,lineHeight:1.6}}>
|
| 629 |
-
Enter the verification code to save it to your session context.
|
| 630 |
-
</p>
|
| 631 |
-
<span className="kv-label">Field: <span style={{color:'var(--accent)'}}>{otpPrompt.otpFieldName}</span></span>
|
| 632 |
-
<input
|
| 633 |
-
className="input"
|
| 634 |
-
autoFocus
|
| 635 |
-
placeholder="Enter codeβ¦"
|
| 636 |
-
value={otpInput}
|
| 637 |
-
onChange={e => setOtpInput(e.target.value)}
|
| 638 |
-
onKeyDown={e => { if (e.key === 'Enter') handleOtpSubmit(); }}
|
| 639 |
-
style={{marginBottom:12}}
|
| 640 |
-
/>
|
| 641 |
-
<div style={{display:'flex',gap:8}}>
|
| 642 |
-
<button onClick={handleOtpSubmit} className="btn btn-primary" style={{flex:1}}>Save & Continue</button>
|
| 643 |
-
<button onClick={() => setOtpPrompt(null)} className="btn">Cancel</button>
|
| 644 |
-
</div>
|
| 645 |
-
</div>
|
| 646 |
-
</div>
|
| 647 |
-
</div>
|
| 648 |
-
)}
|
| 649 |
-
|
| 650 |
-
{/* Selection modal */}
|
| 651 |
-
{selectionPrompt && (
|
| 652 |
-
<div style={{position:'fixed',inset:0,zIndex:50,display:'flex',alignItems:'center',justifyContent:'center',background:'rgba(0,0,0,0.7)',backdropFilter:'blur(8px)',padding:16}}>
|
| 653 |
-
<div style={{background:'var(--bg-1)',border:'1px solid var(--line-3)',borderRadius:10,width:'100%',maxWidth:480,maxHeight:'80vh',overflow:'hidden',display:'flex',flexDirection:'column',boxShadow:'var(--shadow-md)'}}>
|
| 654 |
-
<div style={{padding:'12px 16px',borderBottom:'1px solid var(--line-1)',display:'flex',alignItems:'center',justifyContent:'space-between',flexShrink:0}}>
|
| 655 |
-
<div style={{display:'flex',alignItems:'center',gap:8}}>
|
| 656 |
-
<Layers size={14} style={{color:'var(--accent)'}}/>
|
| 657 |
-
<span style={{fontSize:13,fontWeight:600,color:'var(--fg-0)'}}>Choose an Option</span>
|
| 658 |
-
</div>
|
| 659 |
-
<button onClick={() => setSelectionPrompt(null)} className="ico-btn"><X size={14}/></button>
|
| 660 |
-
</div>
|
| 661 |
-
<div style={{padding:20,overflowY:'auto'}}>
|
| 662 |
-
<p style={{fontSize:12,color:'var(--fg-2)',marginBottom:14,lineHeight:1.6}}>
|
| 663 |
-
Select one to save as <code style={{color:'var(--accent)'}}>{selectionPrompt.fieldName}</code>.
|
| 664 |
-
</p>
|
| 665 |
-
<div style={{display:'flex',flexDirection:'column',gap:6,marginBottom:14}}>
|
| 666 |
-
{selectionPrompt.options.map((opt, idx) => (
|
| 667 |
-
<button
|
| 668 |
-
key={idx}
|
| 669 |
-
onClick={() => handleSelectionSubmit(opt)}
|
| 670 |
-
className="col-card"
|
| 671 |
-
style={{textAlign:'left',padding:'10px 14px',borderRadius:6,cursor:'pointer'}}
|
| 672 |
-
>
|
| 673 |
-
<div style={{fontSize:13,color:'var(--fg-0)',fontWeight:500,marginBottom:2}}>
|
| 674 |
-
{opt.label || 'Option'}
|
| 675 |
-
</div>
|
| 676 |
-
<div style={{fontSize:10.5,color:'var(--fg-3)',overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'}}>
|
| 677 |
-
{typeof opt.value === 'object' ? JSON.stringify(opt.value) : String(opt.value)}
|
| 678 |
-
</div>
|
| 679 |
-
</button>
|
| 680 |
-
))}
|
| 681 |
-
</div>
|
| 682 |
-
{selectionPrompt.responseBody && (
|
| 683 |
-
<details style={{cursor:'pointer'}}>
|
| 684 |
-
<summary style={{fontSize:11,color:'var(--fg-3)',display:'flex',alignItems:'center',gap:6,marginBottom:6}}>
|
| 685 |
-
<Code size={12}/> Raw response
|
| 686 |
-
</summary>
|
| 687 |
-
<pre className="code" style={{maxHeight:160}}>
|
| 688 |
-
{(() => { try { return JSON.stringify(JSON.parse(selectionPrompt.responseBody), null, 2); } catch { return selectionPrompt.responseBody; } })()}
|
| 689 |
-
</pre>
|
| 690 |
-
</details>
|
| 691 |
-
)}
|
| 692 |
-
<button onClick={() => setSelectionPrompt(null)} className="btn" style={{width:'100%',justifyContent:'center',marginTop:8}}>
|
| 693 |
-
Cancel
|
| 694 |
-
</button>
|
| 695 |
-
</div>
|
| 696 |
-
</div>
|
| 697 |
-
</div>
|
| 698 |
-
)}
|
| 699 |
-
</div>
|
| 700 |
-
</div>
|
| 701 |
-
|
| 702 |
-
{/* Scenario composer β pinned to bottom */}
|
| 703 |
-
<div style={{borderTop:'1px solid var(--line-1)',background:'var(--bg-1)',flexShrink:0}}>
|
| 704 |
-
<div style={{maxWidth:900,margin:'0 auto',padding:'14px 32px'}}>
|
| 705 |
-
<div className="composer">
|
| 706 |
-
<div className="composer-head">
|
| 707 |
-
<span className="dot"/>
|
| 708 |
-
<span>scenario.txt</span>
|
| 709 |
-
{activeSpecName && activeSpecName !== 'None' && (
|
| 710 |
-
<><span style={{color:'var(--fg-4)'}}>Β·</span><span style={{color:'var(--fg-3)'}}>{activeSpecName}</span></>
|
| 711 |
-
)}
|
| 712 |
-
</div>
|
| 713 |
-
<textarea
|
| 714 |
-
rows={2}
|
| 715 |
-
placeholder={activeSpecId ? "Describe a test scenario, e.g. 'Sign in, create an order, charge it, verify paid'" : "Load a collection from the sidebar to begin"}
|
| 716 |
-
disabled={!activeSpecId || isPlanning}
|
| 717 |
-
value={scenario}
|
| 718 |
-
onChange={e => setScenario(e.target.value)}
|
| 719 |
-
onKeyDown={e => {
|
| 720 |
-
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
| 721 |
-
e.preventDefault();
|
| 722 |
-
handleGeneratePlan();
|
| 723 |
-
}
|
| 724 |
-
}}
|
| 725 |
-
/>
|
| 726 |
-
<div className="composer-foot">
|
| 727 |
-
<div className="hint">
|
| 728 |
-
<kbd>β</kbd><kbd>β΅</kbd> generate plan
|
| 729 |
-
</div>
|
| 730 |
-
<button className="btn btn-ghost" onClick={() => setScenario('')}>Clear</button>
|
| 731 |
-
<button
|
| 732 |
-
onClick={handleGeneratePlan}
|
| 733 |
-
disabled={!activeSpecId || isPlanning || !scenario.trim()}
|
| 734 |
-
className="btn btn-primary"
|
| 735 |
-
>
|
| 736 |
-
{isPlanning
|
| 737 |
-
? <><RefreshCw size={13} style={{animation:'spin 1s linear infinite'}}/> Planningβ¦</>
|
| 738 |
-
: <><Sparkles size={13}/> Generate plan</>}
|
| 739 |
-
</button>
|
| 740 |
-
</div>
|
| 741 |
-
</div>
|
| 742 |
-
</div>
|
| 743 |
-
</div>
|
| 744 |
-
|
| 745 |
-
</div>
|
| 746 |
-
)}
|
| 747 |
-
|
| 748 |
-
{/* OTHER PAGES */}
|
| 749 |
-
{activePage === 'collections' && (
|
| 750 |
-
<CollectionsPage onCollectionSelected={() => setActivePage('workflow')}/>
|
| 751 |
-
)}
|
| 752 |
-
{activePage === 'profile' && <ProfilePage/>}
|
| 753 |
-
{activePage === 'history' && <HistoryPage/>}
|
| 754 |
-
{activePage === 'media' && (
|
| 755 |
-
<MediaHubPage activeSpecId={activeSpecId} activeSpecName={activeSpecName}/>
|
| 756 |
-
)}
|
| 757 |
-
{activePage === 'settings' && <SettingsPage/>}
|
| 758 |
-
{activePage === 'chat' && (
|
| 759 |
-
<ChatAssistant
|
| 760 |
-
onOpenInExecutionPanel={() => setActivePage('workflow')}
|
| 761 |
-
executeStepFromChat={async (stepDef, changes) => {
|
| 762 |
-
setActivePage('workflow');
|
| 763 |
-
await executeStep(stepDef);
|
| 764 |
-
return {
|
| 765 |
-
step_definition: stepDef,
|
| 766 |
-
response: stepResults[stepDef.step]?.response,
|
| 767 |
-
analysis: stepResults[stepDef.step]?.analysis,
|
| 768 |
-
};
|
| 769 |
-
}}
|
| 770 |
-
/>
|
| 771 |
-
)}
|
| 772 |
|
| 773 |
</main>
|
| 774 |
-
|
| 775 |
-
{/* ββ Right context panel (workflow page only) βββββββββ */}
|
| 776 |
-
{activePage === 'workflow' && (
|
| 777 |
-
<aside style={{
|
| 778 |
-
display:'flex',
|
| 779 |
-
flexShrink:0,
|
| 780 |
-
background:'var(--bg-1)',
|
| 781 |
-
borderLeft:'1px solid var(--line-1)',
|
| 782 |
-
transition:'width 280ms ease',
|
| 783 |
-
width: rightPanelOpen ? (rightPanelMode === 'chat' ? 360 : 300) : 0,
|
| 784 |
-
overflow:'hidden',
|
| 785 |
-
}}>
|
| 786 |
-
<div style={{width: rightPanelMode === 'chat' ? 360 : 300, height:'100%', display:'flex', flexDirection:'column', flexShrink:0}}>
|
| 787 |
-
|
| 788 |
-
{/* Panel tab header */}
|
| 789 |
-
<div style={{height:48,display:'flex',alignItems:'center',borderBottom:'1px solid var(--line-1)',padding:'0 8px',gap:4,flexShrink:0}}>
|
| 790 |
-
<div style={{display:'flex',flex:1,background:'var(--bg-2)',borderRadius:4,padding:2}}>
|
| 791 |
-
<button
|
| 792 |
-
onClick={() => setRightPanelMode('context')}
|
| 793 |
-
style={{
|
| 794 |
-
flex:1,padding:'4px 8px',borderRadius:3,border:0,
|
| 795 |
-
fontSize:10.5,fontWeight:600,letterSpacing:'0.08em',textTransform:'uppercase',
|
| 796 |
-
background: rightPanelMode === 'context' ? 'var(--bg-0)' : 'transparent',
|
| 797 |
-
color: rightPanelMode === 'context' ? 'var(--fg-0)' : 'var(--fg-3)',
|
| 798 |
-
display:'flex',alignItems:'center',justifyContent:'center',gap:5,
|
| 799 |
-
transition:'all 120ms',cursor:'pointer',
|
| 800 |
-
}}
|
| 801 |
-
>
|
| 802 |
-
<Database size={10}/> Context
|
| 803 |
-
</button>
|
| 804 |
-
<button
|
| 805 |
-
onClick={() => setRightPanelMode('chat')}
|
| 806 |
-
style={{
|
| 807 |
-
flex:1,padding:'4px 8px',borderRadius:3,border:0,
|
| 808 |
-
fontSize:10.5,fontWeight:600,letterSpacing:'0.08em',textTransform:'uppercase',
|
| 809 |
-
background: rightPanelMode === 'chat' ? 'var(--bg-0)' : 'transparent',
|
| 810 |
-
color: rightPanelMode === 'chat' ? 'var(--accent)' : 'var(--fg-3)',
|
| 811 |
-
display:'flex',alignItems:'center',justifyContent:'center',gap:5,
|
| 812 |
-
transition:'all 120ms',cursor:'pointer',
|
| 813 |
-
}}
|
| 814 |
-
>
|
| 815 |
-
<Bot size={10}/> AI
|
| 816 |
-
</button>
|
| 817 |
-
</div>
|
| 818 |
-
<button
|
| 819 |
-
onClick={() => setRightPanelOpen(false)}
|
| 820 |
-
className="ico-btn"
|
| 821 |
-
title="Collapse panel"
|
| 822 |
-
>
|
| 823 |
-
<ChevronRight size={14}/>
|
| 824 |
-
</button>
|
| 825 |
-
</div>
|
| 826 |
-
|
| 827 |
-
{/* Context panel */}
|
| 828 |
-
<div style={{flex:1,overflowY:'auto',padding:14,display: rightPanelMode === 'context' ? 'flex' : 'none',flexDirection:'column',gap:16}}>
|
| 829 |
-
<section>
|
| 830 |
-
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',marginBottom:8}}>
|
| 831 |
-
<span className="h-eyebrow">Session Variables</span>
|
| 832 |
-
<button onClick={refreshSessionContext} className="ico-btn" style={{width:22,height:22}} title="Refresh">
|
| 833 |
-
<RefreshCw size={11}/>
|
| 834 |
-
</button>
|
| 835 |
-
</div>
|
| 836 |
-
<div className="panel" style={{overflow:'hidden'}}>
|
| 837 |
-
{Object.keys(sessionContextVars || {}).length === 0 ? (
|
| 838 |
-
<div style={{padding:14,textAlign:'center'}}>
|
| 839 |
-
<Circle size={18} style={{margin:'0 auto 6px',color:'var(--fg-4)',display:'block'}} strokeWidth={1.5}/>
|
| 840 |
-
<p style={{fontSize:11,color:'var(--fg-3)',margin:0,fontStyle:'italic'}}>No variables extracted</p>
|
| 841 |
-
</div>
|
| 842 |
-
) : (
|
| 843 |
-
Object.entries(sessionContextVars).map(([k, v]) => (
|
| 844 |
-
<div key={k} style={{padding:'6px 12px',borderBottom:'1px solid var(--line-1)'}}>
|
| 845 |
-
<div style={{fontSize:10,fontWeight:600,color:'var(--accent)',marginBottom:2}}>{k}</div>
|
| 846 |
-
<div style={{fontSize:11,color:'var(--fg-2)',overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'}}>{String(v)}</div>
|
| 847 |
-
</div>
|
| 848 |
-
))
|
| 849 |
-
)}
|
| 850 |
-
</div>
|
| 851 |
-
</section>
|
| 852 |
-
|
| 853 |
-
<section>
|
| 854 |
-
<div style={{marginBottom:8}}>
|
| 855 |
-
<span className="h-eyebrow">Test Credentials</span>
|
| 856 |
-
</div>
|
| 857 |
-
<div className="panel" style={{overflow:'hidden'}}>
|
| 858 |
-
{Object.keys(storedCredentials || {}).length === 0 ? (
|
| 859 |
-
<div style={{padding:14,textAlign:'center'}}>
|
| 860 |
-
<Circle size={18} style={{margin:'0 auto 6px',color:'var(--fg-4)',display:'block'}} strokeWidth={1.5}/>
|
| 861 |
-
<p style={{fontSize:11,color:'var(--fg-3)',margin:0,fontStyle:'italic'}}>No credentials loaded</p>
|
| 862 |
-
</div>
|
| 863 |
-
) : (
|
| 864 |
-
Object.entries(storedCredentials).filter(([k]) => k !== '_clear').map(([k, v]) => {
|
| 865 |
-
const isSensitive = k.toLowerCase().match(/(password|token|jwt|secret|bearer)/);
|
| 866 |
-
const display = isSensitive && v ? `${String(v).slice(0,4)}β’β’β’β’` : String(v);
|
| 867 |
-
return (
|
| 868 |
-
<div key={k} style={{padding:'6px 12px',borderBottom:'1px solid var(--line-1)'}}>
|
| 869 |
-
<div style={{fontSize:10,fontWeight:600,color:'var(--accent)',marginBottom:2}}>{k}</div>
|
| 870 |
-
<div style={{fontSize:11,color:'var(--fg-2)',overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'}}>{display}</div>
|
| 871 |
-
</div>
|
| 872 |
-
);
|
| 873 |
-
})
|
| 874 |
-
)}
|
| 875 |
-
</div>
|
| 876 |
-
</section>
|
| 877 |
-
</div>
|
| 878 |
-
|
| 879 |
-
{/* Chat panel */}
|
| 880 |
-
<div style={{flex:1,minHeight:0,overflow:'hidden',display: rightPanelMode === 'chat' ? 'flex' : 'none',flexDirection:'column'}}>
|
| 881 |
-
<ChatAssistant
|
| 882 |
-
compact={true}
|
| 883 |
-
allStepResultsProp={stepResults}
|
| 884 |
-
lastStepResultProp={
|
| 885 |
-
Object.keys(stepResults).length > 0
|
| 886 |
-
? stepResults[Math.max(...Object.keys(stepResults).map(Number))]
|
| 887 |
-
: null
|
| 888 |
-
}
|
| 889 |
-
executeStepFromChat={async (stepDef, changes) => {
|
| 890 |
-
const modifiedStep = changes && Object.keys(changes).length > 0
|
| 891 |
-
? {
|
| 892 |
-
...stepDef,
|
| 893 |
-
body: changes.body !== undefined ? { ...(stepDef.body || {}), ...changes.body } : stepDef.body,
|
| 894 |
-
query_params: changes.query_params !== undefined ? { ...(stepDef.query_params || {}), ...changes.query_params } : stepDef.query_params,
|
| 895 |
-
headers: changes.headers !== undefined ? { ...(stepDef.headers || {}), ...changes.headers } : stepDef.headers,
|
| 896 |
-
path_params: changes.path_params !== undefined ? { ...(stepDef.path_params || {}), ...changes.path_params } : stepDef.path_params,
|
| 897 |
-
...Object.fromEntries(Object.entries(changes).filter(([k]) => !['body','query_params','headers','path_params'].includes(k)))
|
| 898 |
-
}
|
| 899 |
-
: stepDef;
|
| 900 |
-
await executeStep(modifiedStep);
|
| 901 |
-
return {
|
| 902 |
-
step_definition: modifiedStep,
|
| 903 |
-
response: stepResults[modifiedStep.step]?.response,
|
| 904 |
-
analysis: stepResults[modifiedStep.step]?.analysis,
|
| 905 |
-
};
|
| 906 |
-
}}
|
| 907 |
-
/>
|
| 908 |
-
</div>
|
| 909 |
-
|
| 910 |
-
</div>
|
| 911 |
-
</aside>
|
| 912 |
-
)}
|
| 913 |
-
|
| 914 |
-
{/* Expand button when panel is collapsed */}
|
| 915 |
-
{!rightPanelOpen && activePage === 'workflow' && (
|
| 916 |
-
<button
|
| 917 |
-
onClick={() => setRightPanelOpen(true)}
|
| 918 |
-
style={{
|
| 919 |
-
position:'absolute',right:0,top:'50%',transform:'translateY(-50%)',
|
| 920 |
-
zIndex:20,padding:'6px 4px',
|
| 921 |
-
background:'var(--bg-1)',color:'var(--fg-2)',
|
| 922 |
-
border:'1px solid var(--line-2)',borderRight:0,
|
| 923 |
-
borderRadius:'4px 0 0 4px',
|
| 924 |
-
transition:'color 120ms',cursor:'pointer',
|
| 925 |
-
}}
|
| 926 |
-
title="Open context panel"
|
| 927 |
-
>
|
| 928 |
-
<ChevronLeft size={14}/>
|
| 929 |
-
</button>
|
| 930 |
-
)}
|
| 931 |
-
|
| 932 |
</div>
|
| 933 |
|
| 934 |
<ToastContainer toasts={toasts} removeToast={removeToast}/>
|
|
@@ -946,14 +201,16 @@ export default function App() {
|
|
| 946 |
}, []);
|
| 947 |
|
| 948 |
if (!isAuthenticated) {
|
| 949 |
-
return <LoginPage onLogin={() => setIsAuthenticated(true)}
|
| 950 |
}
|
| 951 |
|
| 952 |
return (
|
| 953 |
-
<
|
| 954 |
-
<
|
| 955 |
-
<
|
| 956 |
-
|
| 957 |
-
|
|
|
|
|
|
|
| 958 |
);
|
| 959 |
}
|
|
|
|
| 1 |
+
import React, { useState, useEffect } from 'react';
|
| 2 |
+
import { BrowserRouter, Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom';
|
| 3 |
import {
|
| 4 |
Settings, History,
|
| 5 |
+
ChevronRight, ChevronLeft,
|
| 6 |
+
User, Layers, FolderOpen, Bot,
|
| 7 |
+
Sun, Moon,
|
|
|
|
| 8 |
} from 'lucide-react';
|
| 9 |
import { AppProvider, useAppContext } from './components/AppContext';
|
| 10 |
import CollectionsPage from './components/CollectionsPage';
|
|
|
|
| 15 |
import ChatAssistant from './components/ChatAssistant';
|
| 16 |
import { ToastContainer } from './components/Toast';
|
| 17 |
import ErrorBoundary from './components/ErrorBoundary';
|
|
|
|
| 18 |
import LoginPage from './components/LoginPage';
|
| 19 |
+
import WorkflowPage from './pages/WorkflowPage';
|
| 20 |
+
import { AuthService } from './services/api';
|
| 21 |
|
|
|
|
| 22 |
const WorkflowIcon = ({ size = 15, className = '' }) => (
|
| 23 |
<svg width={size} height={size} viewBox="0 0 24 24" fill="none"
|
| 24 |
stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round"
|
|
|
|
| 30 |
);
|
| 31 |
|
| 32 |
function MainApp() {
|
| 33 |
+
const { activeSpecId, activeSpecName, toasts, removeToast } = useAppContext();
|
| 34 |
+
const navigate = useNavigate();
|
| 35 |
+
const location = useLocation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 37 |
const [theme, setTheme] = useState('dark');
|
| 38 |
const [collapsed, setCollapsed] = useState(false);
|
|
|
|
|
|
|
| 39 |
|
|
|
|
| 40 |
useEffect(() => {
|
| 41 |
document.documentElement.setAttribute('data-theme', theme);
|
| 42 |
}, [theme]);
|
| 43 |
|
|
|
|
| 44 |
useEffect(() => {
|
| 45 |
+
const handle = (e) => navigate(`/${e.detail}`);
|
| 46 |
window.addEventListener('nav-change', handle);
|
| 47 |
return () => window.removeEventListener('nav-change', handle);
|
| 48 |
+
}, [navigate]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
const activePage = location.pathname.replace('/', '') || 'workflow';
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
const NAV1 = [
|
| 53 |
{ id: 'workflow', label: 'Workflow', Icon: WorkflowIcon, kbd: '1' },
|
| 54 |
{ id: 'collections', label: 'Collections', Icon: Layers, kbd: '2' },
|
| 55 |
{ id: 'profile', label: 'Profile', Icon: User, kbd: '3' },
|
| 56 |
];
|
| 57 |
const NAV2 = [
|
| 58 |
+
{ id: 'history', label: 'History', Icon: History, kbd: '4' },
|
| 59 |
{ id: 'media', label: 'Media hub', Icon: FolderOpen, kbd: '5' },
|
| 60 |
+
{ id: 'chat', label: 'Assistant', Icon: Bot, kbd: '6' },
|
| 61 |
+
{ id: 'settings', label: 'Settings', Icon: Settings, kbd: '7' },
|
| 62 |
];
|
| 63 |
|
| 64 |
return (
|
|
|
|
| 80 |
onClick={() => setCollapsed(c => !c)}
|
| 81 |
title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
| 82 |
>
|
| 83 |
+
{collapsed ? <ChevronRight size={13}/> : <ChevronLeft size={13}/>}
|
|
|
|
|
|
|
| 84 |
</button>
|
| 85 |
</div>
|
| 86 |
|
|
|
|
| 90 |
<button
|
| 91 |
key={n.id}
|
| 92 |
className={`sb-item${activePage === n.id ? ' active' : ''}`}
|
| 93 |
+
onClick={() => navigate(`/${n.id}`)}
|
| 94 |
title={collapsed ? n.label : undefined}
|
| 95 |
>
|
| 96 |
<n.Icon size={15} className="ico"/>
|
|
|
|
| 106 |
<button
|
| 107 |
key={n.id}
|
| 108 |
className={`sb-item${activePage === n.id ? ' active' : ''}`}
|
| 109 |
+
onClick={() => navigate(`/${n.id}`)}
|
| 110 |
title={collapsed ? n.label : undefined}
|
| 111 |
>
|
| 112 |
<n.Icon size={15} className="ico"/>
|
|
|
|
| 118 |
|
| 119 |
<div className="sb-foot">
|
| 120 |
<span className="dot"/>
|
| 121 |
+
{!collapsed && <><span>session live</span><span style={{ flex: 1 }}/></>}
|
| 122 |
</div>
|
| 123 |
</aside>
|
| 124 |
|
|
|
|
| 139 |
|
| 140 |
<div className="spacer"/>
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
{/* Theme toggle */}
|
| 143 |
<div className="theme-toggle">
|
| 144 |
<button
|
|
|
|
| 158 |
</div>
|
| 159 |
</header>
|
| 160 |
|
| 161 |
+
{/* ββ Page routes ββββββββββββββββββββββββββββββββββββ */}
|
| 162 |
+
<Routes>
|
| 163 |
+
<Route path="/" element={<Navigate to="/workflow" replace/>}/>
|
| 164 |
+
<Route path="/workflow" element={<WorkflowPage/>}/>
|
| 165 |
+
<Route path="/collections" element={
|
| 166 |
+
<CollectionsPage onCollectionSelected={() => navigate('/workflow')}/>
|
| 167 |
+
}/>
|
| 168 |
+
<Route path="/profile" element={<ProfilePage/>}/>
|
| 169 |
+
<Route path="/history" element={<HistoryPage/>}/>
|
| 170 |
+
<Route path="/media" element={
|
| 171 |
+
<MediaHubPage activeSpecId={activeSpecId} activeSpecName={activeSpecName}/>
|
| 172 |
+
}/>
|
| 173 |
+
<Route path="/settings" element={<SettingsPage/>}/>
|
| 174 |
+
<Route path="/chat" element={
|
| 175 |
+
<ChatAssistant
|
| 176 |
+
onOpenInExecutionPanel={() => navigate('/workflow')}
|
| 177 |
+
executeStepFromChat={async () => {
|
| 178 |
+
navigate('/workflow');
|
| 179 |
+
return {};
|
| 180 |
+
}}
|
| 181 |
+
/>
|
| 182 |
+
}/>
|
| 183 |
+
<Route path="*" element={<Navigate to="/workflow" replace/>}/>
|
| 184 |
+
</Routes>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
</main>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
</div>
|
| 188 |
|
| 189 |
<ToastContainer toasts={toasts} removeToast={removeToast}/>
|
|
|
|
| 201 |
}, []);
|
| 202 |
|
| 203 |
if (!isAuthenticated) {
|
| 204 |
+
return <LoginPage onLogin={() => setIsAuthenticated(true)}/>;
|
| 205 |
}
|
| 206 |
|
| 207 |
return (
|
| 208 |
+
<BrowserRouter>
|
| 209 |
+
<AppProvider>
|
| 210 |
+
<ErrorBoundary>
|
| 211 |
+
<MainApp/>
|
| 212 |
+
</ErrorBoundary>
|
| 213 |
+
</AppProvider>
|
| 214 |
+
</BrowserRouter>
|
| 215 |
);
|
| 216 |
}
|
frontend-react/src/components/CollectionsPage.jsx
CHANGED
|
@@ -16,111 +16,166 @@ const CollectionsPage = ({ onCollectionSelected }) => {
|
|
| 16 |
const handleFileUpload = async (e) => {
|
| 17 |
const file = e.target.files?.[0];
|
| 18 |
if (!file) return;
|
| 19 |
-
|
| 20 |
setIsUploading(true);
|
| 21 |
try {
|
| 22 |
await SpecService.uploadSpec(file);
|
| 23 |
await fetchCollections();
|
|
|
|
| 24 |
} catch (err) {
|
| 25 |
-
console.error(
|
| 26 |
-
addToast('error', err.message ||
|
| 27 |
} finally {
|
| 28 |
setIsUploading(false);
|
| 29 |
if (fileInputRef.current) fileInputRef.current.value = '';
|
| 30 |
}
|
| 31 |
};
|
| 32 |
|
| 33 |
-
const filteredSpecs = collections.filter(spec =>
|
| 34 |
spec.name.toLowerCase().includes(searchQuery.toLowerCase())
|
| 35 |
);
|
| 36 |
|
| 37 |
return (
|
| 38 |
-
<div className="
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
<
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</div>
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
type="text"
|
| 52 |
-
placeholder="Search collections
|
| 53 |
-
className="bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] text-[var(--text-primary)] text-xs pl-9 pr-3 py-1.5 rounded-md w-64 outline-none focus:border-[var(--accent-primary)]"
|
| 54 |
value={searchQuery}
|
| 55 |
onChange={e => setSearchQuery(e.target.value)}
|
| 56 |
/>
|
|
|
|
| 57 |
</div>
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
className="bg-[var(--accent-gradient)] hover:opacity-90 text-white px-4 py-1.5 text-xs rounded flex items-center space-x-2 transition shadow-lg"
|
| 62 |
-
>
|
| 63 |
-
{isUploading ? <RefreshCw size={14} className="animate-spin" /> : <Plus size={14} />}
|
| 64 |
-
<span>{isUploading ? 'Uploading...' : 'Upload Spec'}</span>
|
| 65 |
-
</button>
|
| 66 |
-
<input
|
| 67 |
-
type="file"
|
| 68 |
-
ref={fileInputRef}
|
| 69 |
-
className="hidden"
|
| 70 |
-
accept=".json,.yaml,.yml"
|
| 71 |
-
onChange={handleFileUpload}
|
| 72 |
-
/>
|
| 73 |
</div>
|
| 74 |
-
</div>
|
| 75 |
|
| 76 |
-
|
| 77 |
{isLoading ? (
|
| 78 |
-
<div
|
| 79 |
-
<RefreshCw size={
|
| 80 |
-
<p
|
| 81 |
</div>
|
| 82 |
) : filteredSpecs.length === 0 ? (
|
| 83 |
-
<div
|
| 84 |
-
<
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
) : (
|
| 88 |
-
<div className="
|
| 89 |
{filteredSpecs.map(spec => (
|
| 90 |
-
<div
|
| 91 |
-
key={spec.id}
|
|
|
|
| 92 |
onClick={() => { loadSpec(spec.id); onCollectionSelected(); }}
|
| 93 |
-
className={`group bg-[var(--bg-secondary)] border rounded-lg p-5 cursor-pointer transition relative overflow-hidden flex flex-col items-center text-center ${activeSpecId === spec.id ? 'border-[var(--accent-primary)] bg-[var(--accent-primary)]/5 ring-1 ring-[var(--accent-primary)]' : 'border-[var(--border-subtle)] hover:border-[var(--text-secondary)]/30 hover:bg-[var(--bg-tertiary)]'}`}
|
| 94 |
>
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
<div className="
|
| 105 |
-
<
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
onClick={(e) => { e.stopPropagation(); deleteSpec(spec.id); }}
|
| 108 |
-
className="
|
|
|
|
|
|
|
| 109 |
>
|
| 110 |
-
<Trash2 size={
|
| 111 |
</button>
|
| 112 |
</div>
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
</div>
|
| 121 |
))}
|
| 122 |
</div>
|
| 123 |
)}
|
|
|
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
);
|
|
|
|
| 16 |
const handleFileUpload = async (e) => {
|
| 17 |
const file = e.target.files?.[0];
|
| 18 |
if (!file) return;
|
| 19 |
+
|
| 20 |
setIsUploading(true);
|
| 21 |
try {
|
| 22 |
await SpecService.uploadSpec(file);
|
| 23 |
await fetchCollections();
|
| 24 |
+
addToast('success', `"${file.name}" uploaded successfully.`);
|
| 25 |
} catch (err) {
|
| 26 |
+
console.error('Upload failed', err);
|
| 27 |
+
addToast('error', err.message || 'Failed to upload spec.');
|
| 28 |
} finally {
|
| 29 |
setIsUploading(false);
|
| 30 |
if (fileInputRef.current) fileInputRef.current.value = '';
|
| 31 |
}
|
| 32 |
};
|
| 33 |
|
| 34 |
+
const filteredSpecs = collections.filter(spec =>
|
| 35 |
spec.name.toLowerCase().includes(searchQuery.toLowerCase())
|
| 36 |
);
|
| 37 |
|
| 38 |
return (
|
| 39 |
+
<div className="page">
|
| 40 |
+
<div className="page-inner">
|
| 41 |
+
|
| 42 |
+
{/* Header */}
|
| 43 |
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}>
|
| 44 |
+
<div>
|
| 45 |
+
<div className="h-eyebrow">Studio</div>
|
| 46 |
+
<h1 style={{ fontSize: 18, fontWeight: 600, color: 'var(--fg-0)', letterSpacing: '-0.01em', margin: '4px 0 0', display: 'flex', alignItems: 'center', gap: 8 }}>
|
| 47 |
+
<Database size={18} style={{ color: 'var(--accent)' }} />
|
| 48 |
+
API Collections
|
| 49 |
+
</h1>
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
| 53 |
+
<button
|
| 54 |
+
className="btn"
|
| 55 |
+
onClick={() => fetchCollections()}
|
| 56 |
+
disabled={isLoading}
|
| 57 |
+
title="Refresh collections"
|
| 58 |
+
>
|
| 59 |
+
<RefreshCw size={13} style={isLoading ? { animation: 'spin 1s linear infinite' } : {}} />
|
| 60 |
+
Refresh
|
| 61 |
+
</button>
|
| 62 |
+
<button
|
| 63 |
+
className="btn btn-primary"
|
| 64 |
+
onClick={() => fileInputRef.current?.click()}
|
| 65 |
+
disabled={isUploading}
|
| 66 |
+
>
|
| 67 |
+
{isUploading
|
| 68 |
+
? <><RefreshCw size={13} style={{ animation: 'spin 1s linear infinite' }} /> Uploadingβ¦</>
|
| 69 |
+
: <><Plus size={13} /> Upload Spec</>}
|
| 70 |
+
</button>
|
| 71 |
+
<input
|
| 72 |
+
type="file"
|
| 73 |
+
ref={fileInputRef}
|
| 74 |
+
style={{ display: 'none' }}
|
| 75 |
+
accept=".json,.yaml,.yml"
|
| 76 |
+
onChange={handleFileUpload}
|
| 77 |
+
/>
|
| 78 |
+
</div>
|
| 79 |
</div>
|
| 80 |
+
|
| 81 |
+
{/* Toolbar */}
|
| 82 |
+
<div className="col-toolbar">
|
| 83 |
+
<div className="search">
|
| 84 |
+
<Search size={13} style={{ color: 'var(--fg-3)', flexShrink: 0 }} />
|
| 85 |
+
<input
|
| 86 |
type="text"
|
| 87 |
+
placeholder="Search collectionsβ¦"
|
|
|
|
| 88 |
value={searchQuery}
|
| 89 |
onChange={e => setSearchQuery(e.target.value)}
|
| 90 |
/>
|
| 91 |
+
<span className="kbd">/</span>
|
| 92 |
</div>
|
| 93 |
+
<span style={{ fontSize: 11, color: 'var(--fg-3)' }}>
|
| 94 |
+
{filteredSpecs.length} {filteredSpecs.length === 1 ? 'collection' : 'collections'}
|
| 95 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
</div>
|
|
|
|
| 97 |
|
| 98 |
+
{/* Content */}
|
| 99 |
{isLoading ? (
|
| 100 |
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: 240, gap: 12 }}>
|
| 101 |
+
<RefreshCw size={28} style={{ color: 'var(--fg-4)', animation: 'spin 1s linear infinite' }} />
|
| 102 |
+
<p style={{ fontSize: 12, color: 'var(--fg-3)', margin: 0 }}>Loading collectionsβ¦</p>
|
| 103 |
</div>
|
| 104 |
) : filteredSpecs.length === 0 ? (
|
| 105 |
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: 260, gap: 14, textAlign: 'center' }}>
|
| 106 |
+
<div style={{ padding: 18, borderRadius: 10, background: 'var(--bg-2)', border: '1px solid var(--line-2)' }}>
|
| 107 |
+
<Database size={32} style={{ color: 'var(--fg-4)' }} strokeWidth={1.5} />
|
| 108 |
+
</div>
|
| 109 |
+
<div>
|
| 110 |
+
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--fg-1)', marginBottom: 4 }}>
|
| 111 |
+
{searchQuery ? 'No collections match your search' : 'No collections yet'}
|
| 112 |
+
</div>
|
| 113 |
+
<p style={{ fontSize: 12, color: 'var(--fg-3)', margin: '0 0 16px', maxWidth: 360, lineHeight: 1.6 }}>
|
| 114 |
+
{searchQuery
|
| 115 |
+
? 'Try a different search term or clear the filter.'
|
| 116 |
+
: 'Upload a Swagger / OpenAPI spec (.json, .yaml) to get started.'}
|
| 117 |
+
</p>
|
| 118 |
+
{!searchQuery && (
|
| 119 |
+
<button className="btn btn-primary" onClick={() => fileInputRef.current?.click()}>
|
| 120 |
+
<Upload size={13} /> Upload your first spec
|
| 121 |
+
</button>
|
| 122 |
+
)}
|
| 123 |
+
</div>
|
| 124 |
</div>
|
| 125 |
) : (
|
| 126 |
+
<div className="col-grid">
|
| 127 |
{filteredSpecs.map(spec => (
|
| 128 |
+
<div
|
| 129 |
+
key={spec.id}
|
| 130 |
+
className={`col-card${activeSpecId === spec.id ? ' active' : ''}`}
|
| 131 |
onClick={() => { loadSpec(spec.id); onCollectionSelected(); }}
|
|
|
|
| 132 |
>
|
| 133 |
+
{/* Active badge */}
|
| 134 |
+
{activeSpecId === spec.id && (
|
| 135 |
+
<div style={{
|
| 136 |
+
position: 'absolute', top: 10, right: 10,
|
| 137 |
+
display: 'inline-flex', alignItems: 'center', gap: 4,
|
| 138 |
+
background: 'var(--accent)', color: '#fff',
|
| 139 |
+
fontSize: 9, fontWeight: 700, letterSpacing: '0.1em',
|
| 140 |
+
textTransform: 'uppercase', padding: '2px 7px', borderRadius: 3,
|
| 141 |
+
}}>
|
| 142 |
+
<Check size={8} /> Active
|
| 143 |
+
</div>
|
| 144 |
+
)}
|
| 145 |
|
| 146 |
+
<div className="top">
|
| 147 |
+
<div style={{
|
| 148 |
+
width: 36, height: 36, display: 'grid', placeItems: 'center',
|
| 149 |
+
borderRadius: 8, background: 'var(--bg-2)', border: '1px solid var(--line-2)',
|
| 150 |
+
flexShrink: 0,
|
| 151 |
+
}}>
|
| 152 |
+
<LayoutTemplate size={18} style={{ color: activeSpecId === spec.id ? 'var(--accent)' : 'var(--fg-2)' }} />
|
| 153 |
+
</div>
|
| 154 |
+
<button
|
| 155 |
onClick={(e) => { e.stopPropagation(); deleteSpec(spec.id); }}
|
| 156 |
+
className="ico-btn"
|
| 157 |
+
title="Delete collection"
|
| 158 |
+
style={{ width: 26, height: 26, color: 'var(--fg-3)' }}
|
| 159 |
>
|
| 160 |
+
<Trash2 size={13} />
|
| 161 |
</button>
|
| 162 |
</div>
|
| 163 |
|
| 164 |
+
<h3 style={{ margin: '0 0 4px', fontSize: 13, fontWeight: 600, color: 'var(--fg-0)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
| 165 |
+
{spec.name}
|
| 166 |
+
</h3>
|
| 167 |
+
<div style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: '0.1em', color: 'var(--fg-3)', fontWeight: 700, marginBottom: 2 }}>
|
| 168 |
+
API Specification
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<div className="meta">
|
| 172 |
+
<span className="id">ID: {spec.id.slice(0, 8)}β¦</span>
|
| 173 |
+
</div>
|
| 174 |
</div>
|
| 175 |
))}
|
| 176 |
</div>
|
| 177 |
)}
|
| 178 |
+
|
| 179 |
</div>
|
| 180 |
</div>
|
| 181 |
);
|
frontend-react/src/index.css
CHANGED
|
@@ -1,43 +1,858 @@
|
|
| 1 |
@import "tailwindcss";
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
|
|
|
|
|
|
|
|
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
::-webkit-scrollbar-thumb {
|
| 37 |
-
background: var(--
|
| 38 |
-
border-radius:
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
-
|
| 41 |
::-webkit-scrollbar-thumb:hover {
|
| 42 |
-
background: var(--
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
@import "tailwindcss";
|
| 2 |
|
| 3 |
+
/* ββ Design tokens ββββββββββββββββββββββββββββββββββββββββββββ */
|
| 4 |
+
:root {
|
| 5 |
+
--font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
html[data-theme="dark"] {
|
| 9 |
+
--bg-0: #0a0a0b;
|
| 10 |
+
--bg-1: #111114;
|
| 11 |
+
--bg-2: #16161a;
|
| 12 |
+
--bg-3: #1d1d22;
|
| 13 |
+
--bg-hov: #232328;
|
| 14 |
+
|
| 15 |
+
--line-1: rgba(255,255,255,0.06);
|
| 16 |
+
--line-2: rgba(255,255,255,0.10);
|
| 17 |
+
--line-3: rgba(255,255,255,0.18);
|
| 18 |
+
|
| 19 |
+
--fg-0: #f4f4f5;
|
| 20 |
+
--fg-1: #c4c4c8;
|
| 21 |
+
--fg-2: #8a8a92;
|
| 22 |
+
--fg-3: #5f5f66;
|
| 23 |
+
--fg-4: #3a3a40;
|
| 24 |
|
| 25 |
+
--accent: #4f8cff;
|
| 26 |
+
--accent-fg: #ffffff;
|
| 27 |
+
--accent-soft: rgba(79,140,255,0.14);
|
| 28 |
+
--accent-line: rgba(79,140,255,0.40);
|
| 29 |
|
| 30 |
+
--ok: #3ecf8e;
|
| 31 |
+
--ok-soft: rgba(62,207,142,0.12);
|
| 32 |
+
--warn: #f5a524;
|
| 33 |
+
--warn-soft: rgba(245,165,36,0.12);
|
| 34 |
+
--err: #f5604a;
|
| 35 |
+
--err-soft: rgba(245,96,74,0.12);
|
| 36 |
|
| 37 |
+
--shadow-sm: 0 1px 0 rgba(255,255,255,0.03), 0 1px 2px rgba(0,0,0,0.4);
|
| 38 |
+
--shadow-md: 0 8px 24px -8px rgba(0,0,0,0.5);
|
| 39 |
|
| 40 |
+
color-scheme: dark;
|
| 41 |
+
|
| 42 |
+
/* ββ Backward-compat aliases (used by existing Tailwind components) ββ */
|
| 43 |
+
--bg-primary: #0a0a0b;
|
| 44 |
+
--bg-secondary: #111114;
|
| 45 |
+
--bg-tertiary: #16161a;
|
| 46 |
+
--bg-elevated: #1d1d22;
|
| 47 |
+
--bg-hover: #232328;
|
| 48 |
+
--border-subtle: rgba(255,255,255,0.06);
|
| 49 |
+
--border-default: rgba(255,255,255,0.10);
|
| 50 |
+
--border-strong: rgba(255,255,255,0.18);
|
| 51 |
+
--text-primary: #f4f4f5;
|
| 52 |
+
--text-secondary: #8a8a92;
|
| 53 |
+
--text-tertiary: #5f5f66;
|
| 54 |
+
--text-muted: #3a3a40;
|
| 55 |
+
--accent-primary: #4f8cff;
|
| 56 |
+
--accent-hover: #6ba1ff;
|
| 57 |
+
--accent-secondary:#22d3ee;
|
| 58 |
+
--accent-glow: rgba(79,140,255,0.14);
|
| 59 |
+
--accent-gradient: linear-gradient(135deg, #4f8cff 0%, #22d3ee 100%);
|
| 60 |
+
--success: #3ecf8e;
|
| 61 |
+
--success-bg: rgba(62,207,142,0.12);
|
| 62 |
+
--warning: #f5a524;
|
| 63 |
+
--warning-bg: rgba(245,165,36,0.12);
|
| 64 |
+
--danger: #f5604a;
|
| 65 |
+
--danger-bg: rgba(245,96,74,0.12);
|
| 66 |
}
|
| 67 |
|
| 68 |
+
html[data-theme="light"] {
|
| 69 |
+
--bg-0: #fafaf9;
|
| 70 |
+
--bg-1: #ffffff;
|
| 71 |
+
--bg-2: #f4f4f2;
|
| 72 |
+
--bg-3: #ececea;
|
| 73 |
+
--bg-hov: #e4e4e1;
|
| 74 |
+
|
| 75 |
+
--line-1: rgba(0,0,0,0.06);
|
| 76 |
+
--line-2: rgba(0,0,0,0.10);
|
| 77 |
+
--line-3: rgba(0,0,0,0.18);
|
| 78 |
+
|
| 79 |
+
--fg-0: #0c0c0d;
|
| 80 |
+
--fg-1: #2a2a2e;
|
| 81 |
+
--fg-2: #595960;
|
| 82 |
+
--fg-3: #898990;
|
| 83 |
+
--fg-4: #b8b8be;
|
| 84 |
+
|
| 85 |
+
--accent: #2563eb;
|
| 86 |
+
--accent-fg: #ffffff;
|
| 87 |
+
--accent-soft: rgba(37,99,235,0.10);
|
| 88 |
+
--accent-line: rgba(37,99,235,0.35);
|
| 89 |
+
|
| 90 |
+
--ok: #16a34a;
|
| 91 |
+
--ok-soft: rgba(22,163,74,0.10);
|
| 92 |
+
--warn: #b45309;
|
| 93 |
+
--warn-soft: rgba(180,83,9,0.10);
|
| 94 |
+
--err: #dc2626;
|
| 95 |
+
--err-soft: rgba(220,38,38,0.10);
|
| 96 |
+
|
| 97 |
+
--shadow-sm: 0 1px 0 rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
|
| 98 |
+
--shadow-md: 0 8px 24px -10px rgba(0,0,0,0.12);
|
| 99 |
+
|
| 100 |
+
color-scheme: light;
|
| 101 |
+
|
| 102 |
+
/* ββ Backward-compat aliases ββ */
|
| 103 |
+
--bg-primary: #fafaf9;
|
| 104 |
+
--bg-secondary: #ffffff;
|
| 105 |
+
--bg-tertiary: #f4f4f2;
|
| 106 |
+
--bg-elevated: #ececea;
|
| 107 |
+
--bg-hover: #e4e4e1;
|
| 108 |
+
--border-subtle: rgba(0,0,0,0.06);
|
| 109 |
+
--border-default: rgba(0,0,0,0.10);
|
| 110 |
+
--border-strong: rgba(0,0,0,0.18);
|
| 111 |
+
--text-primary: #0c0c0d;
|
| 112 |
+
--text-secondary: #595960;
|
| 113 |
+
--text-tertiary: #898990;
|
| 114 |
+
--text-muted: #b8b8be;
|
| 115 |
+
--accent-primary: #2563eb;
|
| 116 |
+
--accent-hover: #3b82f6;
|
| 117 |
+
--accent-secondary:#0891b2;
|
| 118 |
+
--accent-glow: rgba(37,99,235,0.10);
|
| 119 |
+
--accent-gradient: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
|
| 120 |
+
--success: #16a34a;
|
| 121 |
+
--success-bg: rgba(22,163,74,0.10);
|
| 122 |
+
--warning: #b45309;
|
| 123 |
+
--warning-bg: rgba(180,83,9,0.10);
|
| 124 |
+
--danger: #dc2626;
|
| 125 |
+
--danger-bg: rgba(220,38,38,0.10);
|
| 126 |
}
|
| 127 |
|
| 128 |
+
/* ββ Reset & Base βββββββββββββββββββββββββββββββββββββββββββββ */
|
| 129 |
+
*,*::before,*::after { box-sizing: border-box; }
|
| 130 |
+
html, body, #root { height: 100%; }
|
| 131 |
+
body {
|
| 132 |
+
margin: 0;
|
| 133 |
+
font-family: var(--font-mono);
|
| 134 |
+
font-size: 13px;
|
| 135 |
+
line-height: 1.5;
|
| 136 |
+
background: var(--bg-0);
|
| 137 |
+
color: var(--fg-0);
|
| 138 |
+
-webkit-font-smoothing: antialiased;
|
| 139 |
+
-moz-osx-font-smoothing: grayscale;
|
| 140 |
+
overflow: hidden;
|
| 141 |
+
font-feature-settings: "ss01","ss02","cv01";
|
| 142 |
}
|
| 143 |
+
button { font-family: inherit; font-size: inherit; cursor: pointer; }
|
| 144 |
+
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
|
| 145 |
+
::selection { background: var(--accent-soft); }
|
| 146 |
|
| 147 |
+
/* ββ Scrollbars βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 148 |
+
::-webkit-scrollbar { width: 10px; height: 10px; }
|
| 149 |
+
::-webkit-scrollbar-track { background: transparent; }
|
| 150 |
::-webkit-scrollbar-thumb {
|
| 151 |
+
background: var(--line-2);
|
| 152 |
+
border-radius: 999px;
|
| 153 |
+
border: 2px solid transparent;
|
| 154 |
+
background-clip: padding-box;
|
| 155 |
}
|
|
|
|
| 156 |
::-webkit-scrollbar-thumb:hover {
|
| 157 |
+
background: var(--line-3);
|
| 158 |
+
background-clip: padding-box;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/* ββ App layout βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 162 |
+
.app {
|
| 163 |
+
display: flex;
|
| 164 |
+
height: 100%;
|
| 165 |
+
background: var(--bg-0);
|
| 166 |
+
position: relative;
|
| 167 |
+
overflow: hidden;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
/* ββ Sidebar βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 171 |
+
.sidebar {
|
| 172 |
+
border-right: 1px solid var(--line-1);
|
| 173 |
+
background: var(--bg-1);
|
| 174 |
+
display: flex;
|
| 175 |
+
flex-direction: column;
|
| 176 |
+
width: 220px;
|
| 177 |
+
transition: width 180ms ease;
|
| 178 |
+
flex-shrink: 0;
|
| 179 |
+
overflow: hidden;
|
| 180 |
+
}
|
| 181 |
+
.sidebar.collapsed { width: 52px; }
|
| 182 |
+
|
| 183 |
+
.sb-head {
|
| 184 |
+
height: 48px;
|
| 185 |
+
display: flex;
|
| 186 |
+
align-items: center;
|
| 187 |
+
gap: 10px;
|
| 188 |
+
padding: 0 12px;
|
| 189 |
+
border-bottom: 1px solid var(--line-1);
|
| 190 |
+
flex-shrink: 0;
|
| 191 |
+
}
|
| 192 |
+
.sb-mark {
|
| 193 |
+
width: 22px;
|
| 194 |
+
height: 22px;
|
| 195 |
+
border: 1px solid var(--fg-0);
|
| 196 |
+
display: grid;
|
| 197 |
+
place-items: center;
|
| 198 |
+
font-weight: 700;
|
| 199 |
+
font-size: 11px;
|
| 200 |
+
flex-shrink: 0;
|
| 201 |
+
color: var(--fg-0);
|
| 202 |
+
position: relative;
|
| 203 |
+
overflow: visible;
|
| 204 |
+
}
|
| 205 |
+
.sb-mark::after {
|
| 206 |
+
content: "";
|
| 207 |
+
position: absolute;
|
| 208 |
+
width: 5px;
|
| 209 |
+
height: 5px;
|
| 210 |
+
background: var(--accent);
|
| 211 |
+
transform: translate(7px, -7px);
|
| 212 |
+
}
|
| 213 |
+
.sb-name {
|
| 214 |
+
font-weight: 600;
|
| 215 |
+
letter-spacing: -0.02em;
|
| 216 |
+
color: var(--fg-0);
|
| 217 |
+
font-size: 12px;
|
| 218 |
+
white-space: nowrap;
|
| 219 |
+
overflow: hidden;
|
| 220 |
+
flex: 1;
|
| 221 |
+
}
|
| 222 |
+
.sb-name .dim { color: var(--fg-3); font-weight: 500; }
|
| 223 |
+
|
| 224 |
+
.sb-toggle {
|
| 225 |
+
width: 22px;
|
| 226 |
+
height: 22px;
|
| 227 |
+
border: 1px solid var(--line-2);
|
| 228 |
+
background: transparent;
|
| 229 |
+
color: var(--fg-2);
|
| 230 |
+
display: grid;
|
| 231 |
+
place-items: center;
|
| 232 |
+
border-radius: 4px;
|
| 233 |
+
transition: color 120ms, border-color 120ms, background 120ms;
|
| 234 |
+
flex-shrink: 0;
|
| 235 |
+
}
|
| 236 |
+
.sb-toggle:hover { color: var(--fg-0); border-color: var(--line-3); background: var(--bg-2); }
|
| 237 |
+
|
| 238 |
+
.sb-section-label {
|
| 239 |
+
padding: 14px 14px 6px;
|
| 240 |
+
font-size: 10px;
|
| 241 |
+
letter-spacing: 0.12em;
|
| 242 |
+
color: var(--fg-3);
|
| 243 |
+
text-transform: uppercase;
|
| 244 |
+
white-space: nowrap;
|
| 245 |
+
overflow: hidden;
|
| 246 |
+
}
|
| 247 |
+
.sidebar.collapsed .sb-section-label { opacity: 0; height: 0; padding: 0; }
|
| 248 |
+
|
| 249 |
+
.sb-nav { padding: 4px 6px; display: flex; flex-direction: column; gap: 1px; }
|
| 250 |
+
|
| 251 |
+
.sb-item {
|
| 252 |
+
display: flex;
|
| 253 |
+
align-items: center;
|
| 254 |
+
gap: 10px;
|
| 255 |
+
height: 30px;
|
| 256 |
+
padding: 0 8px;
|
| 257 |
+
color: var(--fg-2);
|
| 258 |
+
background: transparent;
|
| 259 |
+
border: 0;
|
| 260 |
+
text-align: left;
|
| 261 |
+
width: 100%;
|
| 262 |
+
border-radius: 4px;
|
| 263 |
+
position: relative;
|
| 264 |
+
transition: color 120ms, background 120ms;
|
| 265 |
+
}
|
| 266 |
+
.sb-item:hover { color: var(--fg-0); background: var(--bg-2); }
|
| 267 |
+
.sb-item.active { color: var(--fg-0); background: var(--bg-2); }
|
| 268 |
+
.sb-item.active::before {
|
| 269 |
+
content: "";
|
| 270 |
+
position: absolute;
|
| 271 |
+
left: -6px;
|
| 272 |
+
top: 6px;
|
| 273 |
+
bottom: 6px;
|
| 274 |
+
width: 2px;
|
| 275 |
+
background: var(--accent);
|
| 276 |
+
border-radius: 0 2px 2px 0;
|
| 277 |
+
}
|
| 278 |
+
.sb-item .ico { width: 15px; height: 15px; flex-shrink: 0; }
|
| 279 |
+
.sb-item .lbl { font-size: 12px; white-space: nowrap; overflow: hidden; flex: 1; }
|
| 280 |
+
.sb-item .kbd {
|
| 281 |
+
font-size: 10px;
|
| 282 |
+
color: var(--fg-3);
|
| 283 |
+
border: 1px solid var(--line-2);
|
| 284 |
+
padding: 1px 5px;
|
| 285 |
+
border-radius: 3px;
|
| 286 |
+
background: var(--bg-0);
|
| 287 |
+
}
|
| 288 |
+
.sidebar.collapsed .sb-item .lbl,
|
| 289 |
+
.sidebar.collapsed .sb-item .kbd { opacity: 0; pointer-events: none; width: 0; overflow: hidden; }
|
| 290 |
+
.sidebar.collapsed .sb-item { justify-content: center; padding: 0; }
|
| 291 |
+
|
| 292 |
+
.sb-foot {
|
| 293 |
+
margin-top: auto;
|
| 294 |
+
padding: 10px 12px;
|
| 295 |
+
border-top: 1px solid var(--line-1);
|
| 296 |
+
display: flex;
|
| 297 |
+
align-items: center;
|
| 298 |
+
gap: 10px;
|
| 299 |
+
color: var(--fg-2);
|
| 300 |
+
font-size: 11px;
|
| 301 |
+
white-space: nowrap;
|
| 302 |
+
overflow: hidden;
|
| 303 |
+
}
|
| 304 |
+
.sb-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
|
| 305 |
+
|
| 306 |
+
/* ββ Main area ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 307 |
+
.main {
|
| 308 |
+
flex: 1;
|
| 309 |
+
display: flex;
|
| 310 |
+
flex-direction: column;
|
| 311 |
+
min-width: 0;
|
| 312 |
+
min-height: 0;
|
| 313 |
+
overflow: hidden;
|
| 314 |
+
background: var(--bg-0);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
/* ββ Topbar ββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 318 |
+
.topbar {
|
| 319 |
+
height: 48px;
|
| 320 |
+
display: flex;
|
| 321 |
+
align-items: center;
|
| 322 |
+
gap: 12px;
|
| 323 |
+
padding: 0 16px;
|
| 324 |
+
border-bottom: 1px solid var(--line-1);
|
| 325 |
+
background: var(--bg-1);
|
| 326 |
+
flex-shrink: 0;
|
| 327 |
+
}
|
| 328 |
+
.crumb {
|
| 329 |
+
display: flex;
|
| 330 |
+
align-items: center;
|
| 331 |
+
gap: 8px;
|
| 332 |
+
font-size: 12px;
|
| 333 |
+
color: var(--fg-2);
|
| 334 |
+
min-width: 0;
|
| 335 |
+
}
|
| 336 |
+
.crumb .sep { color: var(--fg-4); }
|
| 337 |
+
.crumb .here { color: var(--fg-0); font-weight: 500; }
|
| 338 |
+
.topbar .spacer { flex: 1; }
|
| 339 |
+
|
| 340 |
+
/* Base URL input in topbar */
|
| 341 |
+
.url-input {
|
| 342 |
+
display: flex;
|
| 343 |
+
align-items: center;
|
| 344 |
+
height: 28px;
|
| 345 |
+
background: var(--bg-2);
|
| 346 |
+
border: 1px solid var(--line-2);
|
| 347 |
+
border-radius: 4px;
|
| 348 |
+
padding: 0 0 0 8px;
|
| 349 |
+
min-width: 300px;
|
| 350 |
+
transition: border-color 120ms;
|
| 351 |
+
}
|
| 352 |
+
.url-input:focus-within { border-color: var(--accent-line); }
|
| 353 |
+
.url-input .label {
|
| 354 |
+
font-size: 10px;
|
| 355 |
+
color: var(--fg-3);
|
| 356 |
+
text-transform: uppercase;
|
| 357 |
+
letter-spacing: 0.1em;
|
| 358 |
+
padding-right: 8px;
|
| 359 |
+
border-right: 1px solid var(--line-2);
|
| 360 |
+
margin-right: 8px;
|
| 361 |
+
white-space: nowrap;
|
| 362 |
+
}
|
| 363 |
+
.url-input input {
|
| 364 |
+
background: transparent;
|
| 365 |
+
border: 0;
|
| 366 |
+
outline: 0;
|
| 367 |
+
flex: 1;
|
| 368 |
+
font-size: 12px;
|
| 369 |
+
color: var(--fg-0);
|
| 370 |
+
padding: 0 8px 0 0;
|
| 371 |
+
height: 100%;
|
| 372 |
+
min-width: 0;
|
| 373 |
+
}
|
| 374 |
+
.url-input input::placeholder { color: var(--fg-4); }
|
| 375 |
+
|
| 376 |
+
/* Theme toggle */
|
| 377 |
+
.theme-toggle {
|
| 378 |
+
display: inline-flex;
|
| 379 |
+
align-items: center;
|
| 380 |
+
background: var(--bg-2);
|
| 381 |
+
border: 1px solid var(--line-2);
|
| 382 |
+
border-radius: 4px;
|
| 383 |
+
padding: 2px;
|
| 384 |
+
height: 28px;
|
| 385 |
+
}
|
| 386 |
+
.theme-toggle button {
|
| 387 |
+
height: 22px;
|
| 388 |
+
padding: 0 8px;
|
| 389 |
+
background: transparent;
|
| 390 |
+
border: 0;
|
| 391 |
+
color: var(--fg-2);
|
| 392 |
+
font-size: 11px;
|
| 393 |
+
border-radius: 3px;
|
| 394 |
+
display: inline-flex;
|
| 395 |
+
align-items: center;
|
| 396 |
+
gap: 5px;
|
| 397 |
+
transition: background 120ms, color 120ms;
|
| 398 |
+
}
|
| 399 |
+
.theme-toggle button:hover { color: var(--fg-0); }
|
| 400 |
+
.theme-toggle button.on { background: var(--bg-0); color: var(--fg-0); box-shadow: var(--shadow-sm); }
|
| 401 |
+
.theme-toggle .ico { width: 12px; height: 12px; }
|
| 402 |
+
|
| 403 |
+
/* ββ Icon button βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 404 |
+
.ico-btn {
|
| 405 |
+
width: 28px;
|
| 406 |
+
height: 28px;
|
| 407 |
+
display: grid;
|
| 408 |
+
place-items: center;
|
| 409 |
+
background: transparent;
|
| 410 |
+
border: 1px solid var(--line-2);
|
| 411 |
+
border-radius: 4px;
|
| 412 |
+
color: var(--fg-2);
|
| 413 |
+
transition: color 120ms, background 120ms, border-color 120ms;
|
| 414 |
+
}
|
| 415 |
+
.ico-btn:hover { color: var(--fg-0); background: var(--bg-2); border-color: var(--line-3); }
|
| 416 |
+
|
| 417 |
+
/* ββ Buttons ββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 418 |
+
.btn {
|
| 419 |
+
height: 28px;
|
| 420 |
+
padding: 0 12px;
|
| 421 |
+
display: inline-flex;
|
| 422 |
+
align-items: center;
|
| 423 |
+
gap: 6px;
|
| 424 |
+
border-radius: 4px;
|
| 425 |
+
border: 1px solid var(--line-2);
|
| 426 |
+
background: var(--bg-1);
|
| 427 |
+
color: var(--fg-0);
|
| 428 |
+
font-size: 12px;
|
| 429 |
+
font-weight: 500;
|
| 430 |
+
transition: background 120ms, border-color 120ms, color 120ms;
|
| 431 |
+
white-space: nowrap;
|
| 432 |
+
}
|
| 433 |
+
.btn:hover { background: var(--bg-2); border-color: var(--line-3); }
|
| 434 |
+
.btn.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
|
| 435 |
+
.btn.btn-primary:hover { filter: brightness(1.07); }
|
| 436 |
+
.btn.btn-ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
|
| 437 |
+
.btn.btn-ghost:hover { color: var(--fg-0); background: var(--bg-2); }
|
| 438 |
+
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
| 439 |
+
|
| 440 |
+
/* ββ Pills ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 441 |
+
.pill {
|
| 442 |
+
display: inline-flex;
|
| 443 |
+
align-items: center;
|
| 444 |
+
gap: 5px;
|
| 445 |
+
height: 22px;
|
| 446 |
+
padding: 0 8px;
|
| 447 |
+
font-size: 10.5px;
|
| 448 |
+
border-radius: 3px;
|
| 449 |
+
border: 1px solid var(--line-2);
|
| 450 |
+
background: var(--bg-2);
|
| 451 |
+
color: var(--fg-1);
|
| 452 |
+
white-space: nowrap;
|
| 453 |
+
}
|
| 454 |
+
.pill-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
|
| 455 |
+
.pill-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
|
| 456 |
+
.pill-err { color: var(--err); background: var(--err-soft); border-color: transparent; }
|
| 457 |
+
.pill-acc { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
|
| 458 |
+
|
| 459 |
+
/* ββ HTTP method tags βββββββββββββββββββββββββββββββββββββββββββ */
|
| 460 |
+
.method {
|
| 461 |
+
display: inline-block;
|
| 462 |
+
font-size: 10px;
|
| 463 |
+
font-weight: 700;
|
| 464 |
+
letter-spacing: 0.04em;
|
| 465 |
+
padding: 2px 5px;
|
| 466 |
+
border-radius: 3px;
|
| 467 |
+
line-height: 1.2;
|
| 468 |
+
}
|
| 469 |
+
.m-GET { background: rgba(79,140,255,0.16); color: #6ba1ff; }
|
| 470 |
+
.m-POST { background: rgba(62,207,142,0.16); color: #3ecf8e; }
|
| 471 |
+
.m-PUT { background: rgba(245,165,36,0.16); color: #f5a524; }
|
| 472 |
+
.m-DELETE { background: rgba(245,96,74,0.16); color: #f5604a; }
|
| 473 |
+
.m-PATCH { background: rgba(180,120,255,0.16); color: #b48aff; }
|
| 474 |
+
html[data-theme="light"] .m-GET { background: #dbeafe; color: #1e40af; }
|
| 475 |
+
html[data-theme="light"] .m-POST { background: #dcfce7; color: #166534; }
|
| 476 |
+
html[data-theme="light"] .m-PUT { background: #fef3c7; color: #854d0e; }
|
| 477 |
+
html[data-theme="light"] .m-DELETE { background: #fee2e2; color: #991b1b; }
|
| 478 |
+
html[data-theme="light"] .m-PATCH { background: #ede9fe; color: #5b21b6; }
|
| 479 |
+
|
| 480 |
+
/* ββ Page layout ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 481 |
+
.page { flex: 1; min-height: 0; overflow-y: auto; }
|
| 482 |
+
.page-inner { max-width: 1180px; margin: 0 auto; padding: 28px 32px 56px; }
|
| 483 |
+
|
| 484 |
+
.h-eyebrow {
|
| 485 |
+
font-size: 10.5px;
|
| 486 |
+
letter-spacing: 0.14em;
|
| 487 |
+
color: var(--fg-3);
|
| 488 |
+
text-transform: uppercase;
|
| 489 |
+
}
|
| 490 |
+
.h-title { font-size: 18px; letter-spacing: -0.01em; color: var(--fg-0); font-weight: 600; margin: 4px 0 0; }
|
| 491 |
+
.h-sub { color: var(--fg-2); font-size: 12.5px; margin: 4px 0 0; }
|
| 492 |
+
|
| 493 |
+
/* ββ Composer (scenario input box) βββββββββββββββββββββββββββββ */
|
| 494 |
+
.composer {
|
| 495 |
+
background: var(--bg-1);
|
| 496 |
+
border: 1px solid var(--line-2);
|
| 497 |
+
border-radius: 6px;
|
| 498 |
+
overflow: hidden;
|
| 499 |
+
}
|
| 500 |
+
.composer:focus-within { border-color: var(--accent-line); }
|
| 501 |
+
.composer-head {
|
| 502 |
+
display: flex;
|
| 503 |
+
align-items: center;
|
| 504 |
+
gap: 10px;
|
| 505 |
+
padding: 10px 14px;
|
| 506 |
+
border-bottom: 1px solid var(--line-1);
|
| 507 |
+
background: var(--bg-2);
|
| 508 |
+
font-size: 11px;
|
| 509 |
+
color: var(--fg-2);
|
| 510 |
+
}
|
| 511 |
+
.composer-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
|
| 512 |
+
.composer textarea {
|
| 513 |
+
width: 100%;
|
| 514 |
+
min-height: 80px;
|
| 515 |
+
background: transparent;
|
| 516 |
+
border: 0;
|
| 517 |
+
outline: 0;
|
| 518 |
+
padding: 14px;
|
| 519 |
+
resize: none;
|
| 520 |
+
font-size: 13px;
|
| 521 |
+
color: var(--fg-0);
|
| 522 |
+
font-family: var(--font-mono);
|
| 523 |
+
}
|
| 524 |
+
.composer textarea::placeholder { color: var(--fg-3); }
|
| 525 |
+
.composer-foot {
|
| 526 |
+
display: flex;
|
| 527 |
+
align-items: center;
|
| 528 |
+
gap: 8px;
|
| 529 |
+
padding: 8px 10px 8px 12px;
|
| 530 |
+
border-top: 1px solid var(--line-1);
|
| 531 |
+
background: var(--bg-1);
|
| 532 |
+
}
|
| 533 |
+
.composer-foot .hint { font-size: 11px; color: var(--fg-3); flex: 1; }
|
| 534 |
+
.composer-foot .hint kbd {
|
| 535 |
+
font-size: 10px;
|
| 536 |
+
padding: 1px 5px;
|
| 537 |
+
border: 1px solid var(--line-2);
|
| 538 |
+
border-radius: 3px;
|
| 539 |
+
color: var(--fg-2);
|
| 540 |
+
background: var(--bg-2);
|
| 541 |
+
margin: 0 2px;
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
/* ββ Chips ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 545 |
+
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
|
| 546 |
+
.chip {
|
| 547 |
+
height: 22px;
|
| 548 |
+
padding: 0 10px;
|
| 549 |
+
border: 1px solid var(--line-2);
|
| 550 |
+
border-radius: 999px;
|
| 551 |
+
background: var(--bg-2);
|
| 552 |
+
color: var(--fg-2);
|
| 553 |
+
font-size: 11px;
|
| 554 |
+
display: inline-flex;
|
| 555 |
+
align-items: center;
|
| 556 |
+
gap: 4px;
|
| 557 |
+
transition: color 120ms, border-color 120ms, background 120ms;
|
| 558 |
+
white-space: nowrap;
|
| 559 |
+
}
|
| 560 |
+
.chip:hover { color: var(--fg-0); border-color: var(--line-3); background: var(--bg-3); }
|
| 561 |
+
.chip.chip-on { border-color: var(--accent-line); color: var(--fg-0); background: var(--accent-soft); }
|
| 562 |
+
|
| 563 |
+
/* ββ Plan / step cards ββββββββββββββββββββββββββββββββββββββββββ */
|
| 564 |
+
.plan-meta {
|
| 565 |
+
display: flex;
|
| 566 |
+
align-items: center;
|
| 567 |
+
gap: 14px;
|
| 568 |
+
margin: 22px 0 12px;
|
| 569 |
+
flex-wrap: wrap;
|
| 570 |
+
}
|
| 571 |
+
.plan-meta .grow { flex: 1; }
|
| 572 |
+
.progress {
|
| 573 |
+
height: 4px;
|
| 574 |
+
width: 160px;
|
| 575 |
+
background: var(--bg-3);
|
| 576 |
+
border-radius: 999px;
|
| 577 |
+
overflow: hidden;
|
| 578 |
+
border: 1px solid var(--line-1);
|
| 579 |
+
}
|
| 580 |
+
.progress > i { display: block; height: 100%; background: var(--accent); }
|
| 581 |
+
|
| 582 |
+
.step {
|
| 583 |
+
background: var(--bg-1);
|
| 584 |
+
border: 1px solid var(--line-2);
|
| 585 |
+
border-radius: 6px;
|
| 586 |
+
margin-bottom: 8px;
|
| 587 |
+
overflow: hidden;
|
| 588 |
+
transition: border-color 160ms;
|
| 589 |
+
}
|
| 590 |
+
.step:hover { border-color: var(--line-3); }
|
| 591 |
+
.step.is-running { border-color: var(--accent-line); }
|
| 592 |
+
.step.is-ok { border-color: rgba(62,207,142,0.30); }
|
| 593 |
+
.step.is-err { border-color: rgba(245,96,74,0.35); }
|
| 594 |
+
html[data-theme="light"] .step.is-ok { border-color: rgba(22,163,74,0.30); }
|
| 595 |
+
html[data-theme="light"] .step.is-err { border-color: rgba(220,38,38,0.30); }
|
| 596 |
+
|
| 597 |
+
.step-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
|
| 598 |
+
.step-num {
|
| 599 |
+
width: 28px;
|
| 600 |
+
height: 28px;
|
| 601 |
+
border: 1px solid var(--line-2);
|
| 602 |
+
border-radius: 4px;
|
| 603 |
+
display: grid;
|
| 604 |
+
place-items: center;
|
| 605 |
+
font-size: 11px;
|
| 606 |
+
font-weight: 700;
|
| 607 |
+
color: var(--fg-1);
|
| 608 |
+
background: var(--bg-2);
|
| 609 |
+
flex-shrink: 0;
|
| 610 |
+
}
|
| 611 |
+
.step.is-ok .step-num { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
|
| 612 |
+
.step.is-err .step-num { background: var(--err-soft); color: var(--err); border-color: transparent; }
|
| 613 |
+
.step.is-running .step-num { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
|
| 614 |
+
|
| 615 |
+
.step-main { flex: 1; min-width: 0; }
|
| 616 |
+
.step-title { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fg-0); }
|
| 617 |
+
.step-title .endpoint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 618 |
+
.step-title .path { color: var(--fg-1); }
|
| 619 |
+
.step-purpose { color: var(--fg-2); font-size: 11.5px; margin-top: 2px; }
|
| 620 |
+
.step-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
|
| 621 |
+
|
| 622 |
+
.step-body { border-top: 1px solid var(--line-1); background: var(--bg-0); }
|
| 623 |
+
.step-analysis {
|
| 624 |
+
display: flex;
|
| 625 |
+
gap: 10px;
|
| 626 |
+
padding: 10px 14px;
|
| 627 |
+
border-bottom: 1px solid var(--line-1);
|
| 628 |
+
background: var(--bg-2);
|
| 629 |
+
font-size: 12px;
|
| 630 |
+
}
|
| 631 |
+
.step-analysis .tag {
|
| 632 |
+
flex-shrink: 0;
|
| 633 |
+
color: var(--accent);
|
| 634 |
+
font-size: 10px;
|
| 635 |
+
letter-spacing: 0.1em;
|
| 636 |
+
text-transform: uppercase;
|
| 637 |
+
padding-top: 2px;
|
| 638 |
+
}
|
| 639 |
+
.step-analysis .body { color: var(--fg-1); flex: 1; line-height: 1.6; }
|
| 640 |
+
.vars { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
|
| 641 |
+
.var {
|
| 642 |
+
font-size: 10.5px;
|
| 643 |
+
background: var(--bg-1);
|
| 644 |
+
border: 1px solid var(--line-2);
|
| 645 |
+
padding: 2px 6px;
|
| 646 |
+
border-radius: 3px;
|
| 647 |
+
}
|
| 648 |
+
.var .k { color: var(--accent); }
|
| 649 |
+
.var .eq { color: var(--fg-3); margin: 0 2px; }
|
| 650 |
+
.var .v { color: var(--fg-1); }
|
| 651 |
+
|
| 652 |
+
.reqres { display: grid; grid-template-columns: 1fr 1fr; }
|
| 653 |
+
.reqres > div { padding: 12px 14px; min-width: 0; }
|
| 654 |
+
.reqres > div + div { border-left: 1px solid var(--line-1); }
|
| 655 |
+
.rr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
|
| 656 |
+
.rr-head .lbl { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3); }
|
| 657 |
+
|
| 658 |
+
.kv-block {
|
| 659 |
+
background: var(--bg-1);
|
| 660 |
+
border: 1px solid var(--line-1);
|
| 661 |
+
border-radius: 4px;
|
| 662 |
+
padding: 8px 10px;
|
| 663 |
+
font-size: 11.5px;
|
| 664 |
+
}
|
| 665 |
+
.kv-label {
|
| 666 |
+
margin-top: 8px;
|
| 667 |
+
display: block;
|
| 668 |
+
font-size: 9.5px;
|
| 669 |
+
letter-spacing: 0.12em;
|
| 670 |
+
text-transform: uppercase;
|
| 671 |
+
color: var(--fg-3);
|
| 672 |
+
margin-bottom: 4px;
|
| 673 |
+
}
|
| 674 |
+
.kv-row { display: flex; gap: 8px; padding: 1px 0; }
|
| 675 |
+
.kv-row .k { color: var(--fg-3); flex-shrink: 0; }
|
| 676 |
+
.kv-row .v { color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 677 |
+
|
| 678 |
+
pre.code {
|
| 679 |
+
margin: 0;
|
| 680 |
+
background: var(--bg-1);
|
| 681 |
+
border: 1px solid var(--line-1);
|
| 682 |
+
border-radius: 4px;
|
| 683 |
+
padding: 10px;
|
| 684 |
+
font-size: 11.5px;
|
| 685 |
+
color: var(--fg-1);
|
| 686 |
+
overflow: auto;
|
| 687 |
+
max-height: 280px;
|
| 688 |
+
line-height: 1.55;
|
| 689 |
+
white-space: pre;
|
| 690 |
+
font-family: var(--font-mono);
|
| 691 |
+
}
|
| 692 |
+
pre.code .s { color: #6ba1ff; }
|
| 693 |
+
pre.code .n { color: #f5a524; }
|
| 694 |
+
pre.code .b { color: #b48aff; }
|
| 695 |
+
pre.code .k { color: var(--fg-2); }
|
| 696 |
+
html[data-theme="light"] pre.code .s { color: #1e40af; }
|
| 697 |
+
html[data-theme="light"] pre.code .n { color: #b45309; }
|
| 698 |
+
html[data-theme="light"] pre.code .b { color: #5b21b6; }
|
| 699 |
+
|
| 700 |
+
/* ββ Toolbar / search bar βββββββββββββββββββββββββββββββββββββββ */
|
| 701 |
+
.col-toolbar {
|
| 702 |
+
display: flex;
|
| 703 |
+
align-items: center;
|
| 704 |
+
gap: 10px;
|
| 705 |
+
margin: 22px 0 16px;
|
| 706 |
+
}
|
| 707 |
+
.search {
|
| 708 |
+
flex: 1;
|
| 709 |
+
min-width: 0;
|
| 710 |
+
display: flex;
|
| 711 |
+
align-items: center;
|
| 712 |
+
gap: 8px;
|
| 713 |
+
height: 32px;
|
| 714 |
+
padding: 0 12px;
|
| 715 |
+
background: var(--bg-1);
|
| 716 |
+
border: 1px solid var(--line-2);
|
| 717 |
+
border-radius: 4px;
|
| 718 |
+
transition: border-color 120ms;
|
| 719 |
+
}
|
| 720 |
+
.search:focus-within { border-color: var(--accent-line); }
|
| 721 |
+
.search input { background: transparent; border: 0; outline: 0; flex: 1; min-width: 0; color: var(--fg-0); font-size: 12.5px; }
|
| 722 |
+
.search input::placeholder { color: var(--fg-4); }
|
| 723 |
+
.search .kbd { font-size: 10px; color: var(--fg-3); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 3px; background: var(--bg-2); }
|
| 724 |
+
|
| 725 |
+
/* ββ Cards grid βββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 726 |
+
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
|
| 727 |
+
.col-card {
|
| 728 |
+
background: var(--bg-1);
|
| 729 |
+
border: 1px solid var(--line-2);
|
| 730 |
+
border-radius: 6px;
|
| 731 |
+
padding: 14px;
|
| 732 |
+
cursor: pointer;
|
| 733 |
+
transition: border-color 140ms, background 140ms;
|
| 734 |
+
position: relative;
|
| 735 |
+
}
|
| 736 |
+
.col-card:hover { border-color: var(--line-3); background: var(--bg-2); }
|
| 737 |
+
.col-card.active { border-color: var(--accent-line); background: var(--accent-soft); }
|
| 738 |
+
.col-card.active::after {
|
| 739 |
+
content: "";
|
| 740 |
+
position: absolute;
|
| 741 |
+
left: 0;
|
| 742 |
+
top: 14px;
|
| 743 |
+
bottom: 14px;
|
| 744 |
+
width: 2px;
|
| 745 |
+
background: var(--accent);
|
| 746 |
+
border-radius: 0 2px 2px 0;
|
| 747 |
+
}
|
| 748 |
+
.col-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
|
| 749 |
+
.col-card h3 { margin: 0; font-size: 13px; color: var(--fg-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
| 750 |
+
.col-card .meta {
|
| 751 |
+
display: flex;
|
| 752 |
+
gap: 12px;
|
| 753 |
+
flex-wrap: wrap;
|
| 754 |
+
font-size: 11px;
|
| 755 |
+
color: var(--fg-2);
|
| 756 |
+
padding-top: 10px;
|
| 757 |
+
border-top: 1px solid var(--line-1);
|
| 758 |
+
margin-top: 10px;
|
| 759 |
+
}
|
| 760 |
+
.col-card .id { font-size: 10.5px; color: var(--fg-3); }
|
| 761 |
+
|
| 762 |
+
/* ββ Panel (used in Profile, Settings, History) βββββββββββββββββ */
|
| 763 |
+
.panel { background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
|
| 764 |
+
.panel-head {
|
| 765 |
+
display: flex;
|
| 766 |
+
align-items: center;
|
| 767 |
+
gap: 10px;
|
| 768 |
+
padding: 10px 14px;
|
| 769 |
+
border-bottom: 1px solid var(--line-1);
|
| 770 |
+
font-size: 12px;
|
| 771 |
+
color: var(--fg-1);
|
| 772 |
+
background: var(--bg-2);
|
| 773 |
+
}
|
| 774 |
+
.panel-head .grow { flex: 1; }
|
| 775 |
+
.panel-body { padding: 14px; }
|
| 776 |
+
|
| 777 |
+
/* ββ Form fields ββββββββββββββββοΏ½οΏ½οΏ½βββββββββββββββββββββββββββββββ */
|
| 778 |
+
.field { display: grid; gap: 6px; margin-bottom: 12px; }
|
| 779 |
+
.field label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3); }
|
| 780 |
+
.input {
|
| 781 |
+
height: 32px;
|
| 782 |
+
padding: 0 10px;
|
| 783 |
+
background: var(--bg-0);
|
| 784 |
+
border: 1px solid var(--line-2);
|
| 785 |
+
border-radius: 4px;
|
| 786 |
+
color: var(--fg-0);
|
| 787 |
+
font-size: 12.5px;
|
| 788 |
+
outline: none;
|
| 789 |
+
transition: border-color 120ms;
|
| 790 |
+
width: 100%;
|
| 791 |
+
font-family: var(--font-mono);
|
| 792 |
+
}
|
| 793 |
+
.input:focus { border-color: var(--accent-line); }
|
| 794 |
+
.input::placeholder { color: var(--fg-4); }
|
| 795 |
+
|
| 796 |
+
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
| 797 |
+
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
|
| 798 |
+
|
| 799 |
+
.kv-editor { display: flex; flex-direction: column; gap: 6px; }
|
| 800 |
+
|
| 801 |
+
/* ββ Token strip ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 802 |
+
.tokstrip {
|
| 803 |
+
display: inline-flex;
|
| 804 |
+
align-items: center;
|
| 805 |
+
gap: 6px;
|
| 806 |
+
height: 22px;
|
| 807 |
+
padding: 0 8px;
|
| 808 |
+
background: var(--bg-2);
|
| 809 |
+
border: 1px solid var(--line-2);
|
| 810 |
+
border-radius: 3px;
|
| 811 |
+
font-size: 10.5px;
|
| 812 |
+
color: var(--fg-2);
|
| 813 |
+
white-space: nowrap;
|
| 814 |
+
}
|
| 815 |
+
.tokstrip b { color: var(--fg-0); font-weight: 600; }
|
| 816 |
+
.tokstrip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
|
| 817 |
+
|
| 818 |
+
/* ββ Utility helpers ββββββββββββββββββββββββββββββββββββββββββββ */
|
| 819 |
+
.row { display: flex; align-items: center; gap: 8px; }
|
| 820 |
+
.grow { flex: 1; }
|
| 821 |
+
.mb-2 { margin-bottom: 12px; }
|
| 822 |
+
.mb-3 { margin-bottom: 18px; }
|
| 823 |
+
.mb-4 { margin-bottom: 24px; }
|
| 824 |
+
.mt-2 { margin-top: 12px; }
|
| 825 |
+
.mt-3 { margin-top: 18px; }
|
| 826 |
+
.text-dim { color: var(--fg-2); }
|
| 827 |
+
.text-faint { color: var(--fg-3); }
|
| 828 |
+
.strong { color: var(--fg-0); font-weight: 600; }
|
| 829 |
+
|
| 830 |
+
/* ββ Legacy animation helpers (used by existing components) βββββ */
|
| 831 |
+
@keyframes spin { to { transform: rotate(360deg); } }
|
| 832 |
+
@keyframes shimmer { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
|
| 833 |
+
@keyframes pulse-glow { 0%,100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }
|
| 834 |
+
|
| 835 |
+
.animate-shimmer { animation: shimmer 2.5s ease-in-out infinite; }
|
| 836 |
+
.animate-pulse-glow { animation: pulse-glow 2s ease-out infinite; }
|
| 837 |
+
|
| 838 |
+
/* ββ btn-primary gradient (used by existing Tailwind components) β */
|
| 839 |
+
.btn-primary {
|
| 840 |
+
background: var(--accent-gradient);
|
| 841 |
+
position: relative;
|
| 842 |
+
overflow: hidden;
|
| 843 |
+
transition: all 180ms ease;
|
| 844 |
+
}
|
| 845 |
+
.btn-primary::before {
|
| 846 |
+
content: '';
|
| 847 |
+
position: absolute;
|
| 848 |
+
inset: 0;
|
| 849 |
+
background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
|
| 850 |
+
opacity: 0;
|
| 851 |
+
transition: opacity 180ms ease;
|
| 852 |
+
}
|
| 853 |
+
.btn-primary:hover:not(:disabled)::before { opacity: 1; }
|
| 854 |
+
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
|
| 855 |
+
|
| 856 |
+
/* ββ Step card hover (Tailwind-based workflow steps) ββββββββββββ */
|
| 857 |
+
.step-card { transition: border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease; }
|
| 858 |
+
.step-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
|
frontend-react/src/pages/WorkflowPage.jsx
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useState } from 'react';
|
| 2 |
+
import { useNavigate } from 'react-router-dom';
|
| 3 |
+
import {
|
| 4 |
+
ChevronRight, Zap, RefreshCw, X, Bot, Code, Layers,
|
| 5 |
+
Terminal, CheckCircle2, AlertCircle, Circle, Sparkles, Database,
|
| 6 |
+
} from 'lucide-react';
|
| 7 |
+
import { useAppContext } from '../components/AppContext';
|
| 8 |
+
import ChatAssistant from '../components/ChatAssistant';
|
| 9 |
+
import { PlanService, SessionService, SpecService } from '../services/api';
|
| 10 |
+
|
| 11 |
+
const WorkflowIcon = ({ size = 15, className = '' }) => (
|
| 12 |
+
<svg width={size} height={size} viewBox="0 0 24 24" fill="none"
|
| 13 |
+
stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round"
|
| 14 |
+
className={className} aria-hidden="true">
|
| 15 |
+
<rect x="3" y="3" width="6" height="6" rx="1.2"/>
|
| 16 |
+
<rect x="15" y="15" width="6" height="6" rx="1.2"/>
|
| 17 |
+
<path d="M9 6h6a3 3 0 0 1 3 3v6"/>
|
| 18 |
+
</svg>
|
| 19 |
+
);
|
| 20 |
+
|
| 21 |
+
export default function WorkflowPage() {
|
| 22 |
+
const navigate = useNavigate();
|
| 23 |
+
const {
|
| 24 |
+
activeSpecId, activeSpecName, activeBaseUrl, setActiveBaseUrl,
|
| 25 |
+
storedCredentials, setStoredCredentials, saveProfile, parsedSpec,
|
| 26 |
+
sessionContextVars, refreshSessionContext, sessionId,
|
| 27 |
+
executionPlan, setExecutionPlan,
|
| 28 |
+
scenario, setScenario,
|
| 29 |
+
startNewSession,
|
| 30 |
+
addToast,
|
| 31 |
+
} = useAppContext();
|
| 32 |
+
|
| 33 |
+
const [isPlanning, setIsPlanning] = useState(false);
|
| 34 |
+
const [executingStep, setExecutingStep] = useState(null);
|
| 35 |
+
const [isRunningAll, setIsRunningAll] = useState(false);
|
| 36 |
+
const [stepResults, setStepResults] = useState({});
|
| 37 |
+
const [otpPrompt, setOtpPrompt] = useState(null);
|
| 38 |
+
const [otpInput, setOtpInput] = useState('');
|
| 39 |
+
const [selectionPrompt, setSelectionPrompt] = useState(null);
|
| 40 |
+
const [planTokenUsage, setPlanTokenUsage] = useState(null);
|
| 41 |
+
const [totalScenarioTokens, setTotalScenarioTokens] = useState({ prompt: 0, completion: 0, total: 0 });
|
| 42 |
+
const [rightPanelOpen, setRightPanelOpen] = useState(true);
|
| 43 |
+
const [rightPanelMode, setRightPanelMode] = useState('context');
|
| 44 |
+
|
| 45 |
+
/* ββ Plan generation βββββββββββββββββββββββββββββββββββββββ */
|
| 46 |
+
const handleGeneratePlan = async () => {
|
| 47 |
+
if (!activeSpecId) { addToast('warning', 'Please select a collection first.'); return; }
|
| 48 |
+
if (!activeBaseUrl) { addToast('warning', 'Please set a Base URL for this collection.'); return; }
|
| 49 |
+
if (!scenario.trim()) { addToast('warning', 'Please describe a test scenario.'); return; }
|
| 50 |
+
|
| 51 |
+
setIsPlanning(true);
|
| 52 |
+
setPlanTokenUsage(null);
|
| 53 |
+
setStepResults({});
|
| 54 |
+
setTotalScenarioTokens({ prompt: 0, completion: 0, total: 0 });
|
| 55 |
+
|
| 56 |
+
try {
|
| 57 |
+
const newSid = await startNewSession();
|
| 58 |
+
if (!newSid) throw new Error('Could not initialize fresh session');
|
| 59 |
+
|
| 60 |
+
const payload = {
|
| 61 |
+
spec_content: typeof parsedSpec === 'string' ? parsedSpec : JSON.stringify(parsedSpec),
|
| 62 |
+
base_url: activeBaseUrl,
|
| 63 |
+
scenario,
|
| 64 |
+
user_credentials: storedCredentials,
|
| 65 |
+
spec_id: activeSpecId,
|
| 66 |
+
session_id: newSid,
|
| 67 |
+
};
|
| 68 |
+
const data = await PlanService.generatePlan(payload);
|
| 69 |
+
setExecutionPlan(data.execution_plan || []);
|
| 70 |
+
setPlanTokenUsage(data.token_usage);
|
| 71 |
+
|
| 72 |
+
if (data.suggested_credentials && Object.keys(data.suggested_credentials).length > 0) {
|
| 73 |
+
setStoredCredentials(prev => ({ ...prev, ...data.suggested_credentials }));
|
| 74 |
+
}
|
| 75 |
+
if (data.token_usage) {
|
| 76 |
+
setTotalScenarioTokens({
|
| 77 |
+
prompt: data.token_usage.prompt_tokens,
|
| 78 |
+
completion: data.token_usage.completion_tokens,
|
| 79 |
+
total: data.token_usage.total_tokens,
|
| 80 |
+
});
|
| 81 |
+
}
|
| 82 |
+
setStepResults({});
|
| 83 |
+
} catch (err) {
|
| 84 |
+
addToast('error', err.message || 'Plan generation failed.');
|
| 85 |
+
} finally {
|
| 86 |
+
setIsPlanning(false);
|
| 87 |
+
}
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
/* ββ Step execution ββββββββββββββββββββββββββββββββββββββββ */
|
| 91 |
+
const executeStep = async (stepDef) => {
|
| 92 |
+
setExecutingStep(stepDef.step);
|
| 93 |
+
try {
|
| 94 |
+
if (!sessionId) { addToast('error', 'Session not initialized. Please refresh.'); return; }
|
| 95 |
+
if (!activeBaseUrl) { addToast('warning', 'Base URL is missing.'); return; }
|
| 96 |
+
|
| 97 |
+
await refreshSessionContext();
|
| 98 |
+
const payload = {
|
| 99 |
+
session_id: sessionId,
|
| 100 |
+
step_definition: stepDef,
|
| 101 |
+
context_variables: sessionContextVars || {},
|
| 102 |
+
user_credentials: storedCredentials || {},
|
| 103 |
+
base_url: activeBaseUrl,
|
| 104 |
+
spec_id: activeSpecId,
|
| 105 |
+
};
|
| 106 |
+
const execData = await PlanService.executeStep(payload);
|
| 107 |
+
|
| 108 |
+
setStepResults(prev => ({
|
| 109 |
+
...prev,
|
| 110 |
+
[stepDef.step]: {
|
| 111 |
+
request: execData.executed_request,
|
| 112 |
+
response: execData.response,
|
| 113 |
+
analysis: { status: 'pending', response_summary: 'Analyzing response with AIβ¦' },
|
| 114 |
+
token_usage: execData.token_usage || { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
|
| 115 |
+
},
|
| 116 |
+
}));
|
| 117 |
+
|
| 118 |
+
const analyzePayload = {
|
| 119 |
+
session_id: sessionId,
|
| 120 |
+
step: stepDef.step,
|
| 121 |
+
response_data: execData.response,
|
| 122 |
+
step_definition: stepDef,
|
| 123 |
+
};
|
| 124 |
+
const analyzeData = await PlanService.analyzeResponse(analyzePayload);
|
| 125 |
+
|
| 126 |
+
const stepTokens = {
|
| 127 |
+
prompt_tokens: (execData.token_usage?.prompt_tokens || 0) + (analyzeData.token_usage?.prompt_tokens || 0),
|
| 128 |
+
completion_tokens: (execData.token_usage?.completion_tokens || 0) + (analyzeData.token_usage?.completion_tokens || 0),
|
| 129 |
+
total_tokens: (execData.token_usage?.total_tokens || 0) + (analyzeData.token_usage?.total_tokens || 0),
|
| 130 |
+
};
|
| 131 |
+
|
| 132 |
+
setStepResults(prev => ({
|
| 133 |
+
...prev,
|
| 134 |
+
[stepDef.step]: { ...prev[stepDef.step], analysis: analyzeData, token_usage: stepTokens },
|
| 135 |
+
}));
|
| 136 |
+
|
| 137 |
+
setTotalScenarioTokens(prev => ({
|
| 138 |
+
prompt: prev.prompt + stepTokens.prompt_tokens,
|
| 139 |
+
completion: prev.completion + stepTokens.completion_tokens,
|
| 140 |
+
total: prev.total + stepTokens.total_tokens,
|
| 141 |
+
}));
|
| 142 |
+
|
| 143 |
+
await refreshSessionContext();
|
| 144 |
+
|
| 145 |
+
if (analyzeData.is_otp_required) {
|
| 146 |
+
setOtpPrompt({ stepDef, otpFieldName: analyzeData.otp_field_name || 'otp' });
|
| 147 |
+
}
|
| 148 |
+
if (analyzeData.is_selection_required && analyzeData.selection_options?.length > 0) {
|
| 149 |
+
setSelectionPrompt({
|
| 150 |
+
stepDef,
|
| 151 |
+
fieldName: analyzeData.selection_field_name || 'selected_item',
|
| 152 |
+
options: analyzeData.selection_options,
|
| 153 |
+
responseBody: execData.response.body,
|
| 154 |
+
});
|
| 155 |
+
}
|
| 156 |
+
} catch (err) {
|
| 157 |
+
console.error(`Execution failed for step ${stepDef.step}`, err);
|
| 158 |
+
} finally {
|
| 159 |
+
setExecutingStep(null);
|
| 160 |
+
}
|
| 161 |
+
};
|
| 162 |
+
|
| 163 |
+
const runAllSteps = async () => {
|
| 164 |
+
if (!executionPlan?.length) return;
|
| 165 |
+
setIsRunningAll(true);
|
| 166 |
+
for (const step of executionPlan) {
|
| 167 |
+
if (otpPrompt || selectionPrompt) break;
|
| 168 |
+
await executeStep(step);
|
| 169 |
+
}
|
| 170 |
+
setIsRunningAll(false);
|
| 171 |
+
};
|
| 172 |
+
|
| 173 |
+
const handleOtpSubmit = async () => {
|
| 174 |
+
if (!otpInput.trim()) return;
|
| 175 |
+
const { otpFieldName } = otpPrompt;
|
| 176 |
+
try {
|
| 177 |
+
await saveProfile({ extra: { [otpFieldName]: otpInput } });
|
| 178 |
+
setOtpPrompt(null);
|
| 179 |
+
setOtpInput('');
|
| 180 |
+
await refreshSessionContext();
|
| 181 |
+
addToast('success', `OTP "${otpInput}" saved as "${otpFieldName}".`);
|
| 182 |
+
} catch {
|
| 183 |
+
addToast('error', 'Failed to save OTP.');
|
| 184 |
+
}
|
| 185 |
+
};
|
| 186 |
+
|
| 187 |
+
const handleSelectionSubmit = async (option) => {
|
| 188 |
+
if (!selectionPrompt) return;
|
| 189 |
+
try {
|
| 190 |
+
await SessionService.updateContext(sessionId, selectionPrompt.fieldName, option.value);
|
| 191 |
+
setSelectionPrompt(null);
|
| 192 |
+
await refreshSessionContext();
|
| 193 |
+
} catch {
|
| 194 |
+
addToast('error', 'Failed to save selection.');
|
| 195 |
+
}
|
| 196 |
+
};
|
| 197 |
+
|
| 198 |
+
/* ββ Layout ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 199 |
+
return (
|
| 200 |
+
<div style={{ display: 'flex', flex: 1, minHeight: 0, overflow: 'hidden', position: 'relative' }}>
|
| 201 |
+
|
| 202 |
+
{/* ββ Content column ββββββββββββββββββββββββββββββββββββ */}
|
| 203 |
+
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0, overflow: 'hidden' }}>
|
| 204 |
+
|
| 205 |
+
{/* Token info + Base URL bar */}
|
| 206 |
+
{activeSpecId && (
|
| 207 |
+
<div style={{
|
| 208 |
+
display: 'flex', alignItems: 'center', gap: 8, padding: '0 24px',
|
| 209 |
+
height: 40, flexShrink: 0, borderBottom: '1px solid var(--line-1)',
|
| 210 |
+
background: 'var(--bg-1)',
|
| 211 |
+
}}>
|
| 212 |
+
{planTokenUsage && (
|
| 213 |
+
<span className="tokstrip">
|
| 214 |
+
<span className="dot"/>plan <b>{planTokenUsage.total_tokens?.toLocaleString()}</b>
|
| 215 |
+
</span>
|
| 216 |
+
)}
|
| 217 |
+
{totalScenarioTokens.total > 0 && (
|
| 218 |
+
<span className="tokstrip">
|
| 219 |
+
<span className="dot" style={{ background: 'var(--ok)' }}/>
|
| 220 |
+
total <b>{totalScenarioTokens.total.toLocaleString()}</b>
|
| 221 |
+
</span>
|
| 222 |
+
)}
|
| 223 |
+
<div style={{ flex: 1 }}/>
|
| 224 |
+
<div className="url-input">
|
| 225 |
+
<span className="label">base</span>
|
| 226 |
+
<input
|
| 227 |
+
value={activeBaseUrl || ''}
|
| 228 |
+
onChange={e => setActiveBaseUrl(e.target.value)}
|
| 229 |
+
onBlur={async () => {
|
| 230 |
+
if (activeBaseUrl) {
|
| 231 |
+
try { await SpecService.updateBaseUrl(activeSpecId, activeBaseUrl); }
|
| 232 |
+
catch (e) { console.error('URL save failed', e); }
|
| 233 |
+
}
|
| 234 |
+
}}
|
| 235 |
+
placeholder="https://api.example.com"
|
| 236 |
+
spellCheck={false}
|
| 237 |
+
/>
|
| 238 |
+
</div>
|
| 239 |
+
</div>
|
| 240 |
+
)}
|
| 241 |
+
|
| 242 |
+
{/* Scrollable plan area */}
|
| 243 |
+
<div style={{ flex: 1, overflowY: 'auto' }}>
|
| 244 |
+
<div style={{ maxWidth: 900, margin: '0 auto', padding: '32px 32px 24px' }}>
|
| 245 |
+
|
| 246 |
+
{!executionPlan ? (
|
| 247 |
+
/* ββ Empty state ββ */
|
| 248 |
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: '55vh', textAlign: 'center' }}>
|
| 249 |
+
<div style={{ padding: '20px', borderRadius: 12, background: 'var(--bg-2)', border: '1px solid var(--line-2)', marginBottom: 28 }}>
|
| 250 |
+
<Terminal size={36} style={{ color: 'var(--accent)' }} strokeWidth={1.5}/>
|
| 251 |
+
</div>
|
| 252 |
+
<div className="h-eyebrow" style={{ marginBottom: 8 }}>Workflow Studio</div>
|
| 253 |
+
<h1 style={{ fontSize: 22, fontWeight: 600, color: 'var(--fg-0)', letterSpacing: '-0.01em', margin: '0 0 10px' }}>
|
| 254 |
+
AI-Powered API Testing
|
| 255 |
+
</h1>
|
| 256 |
+
<p style={{ fontSize: 12.5, color: 'var(--fg-2)', maxWidth: 420, lineHeight: 1.65, margin: 0 }}>
|
| 257 |
+
{activeSpecId
|
| 258 |
+
? 'Describe a test scenario below and Claude will generate a complete execution plan for your API.'
|
| 259 |
+
: 'Start by loading a collection from the sidebar.'}
|
| 260 |
+
</p>
|
| 261 |
+
{!activeSpecId && (
|
| 262 |
+
<button onClick={() => navigate('/collections')} className="btn" style={{ marginTop: 24, gap: 8 }}>
|
| 263 |
+
<Layers size={13}/> Browse Collections
|
| 264 |
+
</button>
|
| 265 |
+
)}
|
| 266 |
+
</div>
|
| 267 |
+
) : (
|
| 268 |
+
/* ββ Execution plan ββ */
|
| 269 |
+
<div>
|
| 270 |
+
{/* Plan header */}
|
| 271 |
+
<div className="plan-meta">
|
| 272 |
+
<div>
|
| 273 |
+
<div className="h-eyebrow">Execution plan</div>
|
| 274 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 10, marginTop: 2 }}>
|
| 275 |
+
<span style={{ fontSize: 15, fontWeight: 600, color: 'var(--fg-0)' }}>{executionPlan.length} steps</span>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
<div className="grow"/>
|
| 279 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, color: 'var(--fg-2)' }}>
|
| 280 |
+
<span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--ok)', display: 'inline-block' }}/>
|
| 281 |
+
{Object.values(stepResults).filter(r => r.analysis?.status === 'success').length}
|
| 282 |
+
<span style={{ color: 'var(--fg-3)' }}>/ {executionPlan.length} ok</span>
|
| 283 |
+
</div>
|
| 284 |
+
<div className="progress">
|
| 285 |
+
<i style={{ width: `${Math.round((Object.values(stepResults).filter(r => r.analysis?.status === 'success').length / executionPlan.length) * 100)}%` }}/>
|
| 286 |
+
</div>
|
| 287 |
+
<button className="btn" onClick={() => { setExecutionPlan(null); setStepResults({}); }}>
|
| 288 |
+
<RefreshCw size={13}/> Reset
|
| 289 |
+
</button>
|
| 290 |
+
<button
|
| 291 |
+
className="btn btn-primary"
|
| 292 |
+
onClick={runAllSteps}
|
| 293 |
+
disabled={isRunningAll || !!executingStep}
|
| 294 |
+
style={{ gap: 6 }}
|
| 295 |
+
>
|
| 296 |
+
{isRunningAll
|
| 297 |
+
? <><RefreshCw size={13} style={{ animation: 'spin 1s linear infinite' }}/> Runningβ¦</>
|
| 298 |
+
: <><Zap size={13}/> Run all</>}
|
| 299 |
+
</button>
|
| 300 |
+
</div>
|
| 301 |
+
|
| 302 |
+
{/* Steps */}
|
| 303 |
+
{executionPlan.map(step => {
|
| 304 |
+
const isRunning = executingStep === step.step;
|
| 305 |
+
const res = stepResults[step.step];
|
| 306 |
+
const status = res?.analysis?.status;
|
| 307 |
+
const stateClass = status === 'success' ? ' is-ok' : status === 'failed' ? ' is-err' : isRunning ? ' is-running' : '';
|
| 308 |
+
|
| 309 |
+
return (
|
| 310 |
+
<div key={step.step} className={`step${stateClass}`}>
|
| 311 |
+
<div className="step-row">
|
| 312 |
+
<div className="step-num">
|
| 313 |
+
{status === 'success' ? <CheckCircle2 size={14}/>
|
| 314 |
+
: status === 'failed' ? <AlertCircle size={14}/>
|
| 315 |
+
: isRunning ? <RefreshCw size={13} style={{ animation: 'spin 1s linear infinite' }}/>
|
| 316 |
+
: step.step}
|
| 317 |
+
</div>
|
| 318 |
+
|
| 319 |
+
<div className="step-main">
|
| 320 |
+
<div className="step-title">
|
| 321 |
+
<span className={`method m-${step.method}`}>{step.method}</span>
|
| 322 |
+
<span className="endpoint">
|
| 323 |
+
<span className="path">{step.endpoint}</span>
|
| 324 |
+
</span>
|
| 325 |
+
{isRunning && <span className="pill pill-acc">running</span>}
|
| 326 |
+
</div>
|
| 327 |
+
<div className="step-purpose">{step.purpose}</div>
|
| 328 |
+
</div>
|
| 329 |
+
|
| 330 |
+
<div className="step-actions">
|
| 331 |
+
{res?.token_usage && (
|
| 332 |
+
<span className="tokstrip"><b>{res.token_usage.total_tokens.toLocaleString()}</b> tok</span>
|
| 333 |
+
)}
|
| 334 |
+
{res?.response?.status_code !== undefined && (
|
| 335 |
+
<span className={`pill ${res.response.status_code >= 200 && res.response.status_code < 300 ? 'pill-ok' : res.response.status_code >= 400 ? 'pill-err' : 'pill-warn'}`}>
|
| 336 |
+
{res.response.status_code}
|
| 337 |
+
</span>
|
| 338 |
+
)}
|
| 339 |
+
{status === 'failed' && (
|
| 340 |
+
<button
|
| 341 |
+
onClick={() => executeStep(step)}
|
| 342 |
+
disabled={isRunning || isRunningAll}
|
| 343 |
+
className="btn"
|
| 344 |
+
style={{ color: 'var(--warn)', borderColor: 'var(--warn-soft)' }}
|
| 345 |
+
>
|
| 346 |
+
<RefreshCw size={12}/> Retry
|
| 347 |
+
</button>
|
| 348 |
+
)}
|
| 349 |
+
<button
|
| 350 |
+
onClick={() => executeStep(step)}
|
| 351 |
+
disabled={isRunning || isRunningAll}
|
| 352 |
+
className="btn btn-primary"
|
| 353 |
+
>
|
| 354 |
+
{isRunning
|
| 355 |
+
? <><RefreshCw size={12} style={{ animation: 'spin 1s linear infinite' }}/> Running</>
|
| 356 |
+
: <><Zap size={12}/> Execute</>}
|
| 357 |
+
</button>
|
| 358 |
+
</div>
|
| 359 |
+
</div>
|
| 360 |
+
|
| 361 |
+
{res && (
|
| 362 |
+
<div className="step-body">
|
| 363 |
+
<div className="step-analysis">
|
| 364 |
+
<span className="tag">analysis</span>
|
| 365 |
+
<div className="body">
|
| 366 |
+
{res.analysis.response_summary || (status === 'success' ? 'Step completed successfully.' : status === 'failed' ? 'Step encountered an error.' : 'Analyzingβ¦')}
|
| 367 |
+
{res.analysis.extracted_variables && Object.keys(res.analysis.extracted_variables).length > 0 && (
|
| 368 |
+
<div className="vars">
|
| 369 |
+
{Object.entries(res.analysis.extracted_variables).map(([k, v]) => (
|
| 370 |
+
<span className="var" key={k}>
|
| 371 |
+
<span className="k">{k}</span>
|
| 372 |
+
<span className="eq">=</span>
|
| 373 |
+
<span className="v">{String(v).slice(0, 60)}</span>
|
| 374 |
+
</span>
|
| 375 |
+
))}
|
| 376 |
+
</div>
|
| 377 |
+
)}
|
| 378 |
+
</div>
|
| 379 |
+
</div>
|
| 380 |
+
|
| 381 |
+
<div className="reqres">
|
| 382 |
+
<div>
|
| 383 |
+
<div className="rr-head"><span className="lbl">Request</span></div>
|
| 384 |
+
{!res.request ? (
|
| 385 |
+
<div style={{ fontSize: 11, color: 'var(--fg-3)', fontStyle: 'italic' }}>Preparingβ¦</div>
|
| 386 |
+
) : (
|
| 387 |
+
<div style={{ fontSize: 11.5 }}>
|
| 388 |
+
<div className="kv-block" style={{ marginBottom: 8 }}>
|
| 389 |
+
<div className="kv-row">
|
| 390 |
+
<span className="k">URL</span>
|
| 391 |
+
<span className="v">{res.request.url}</span>
|
| 392 |
+
</div>
|
| 393 |
+
</div>
|
| 394 |
+
{res.request.headers && Object.keys(res.request.headers).length > 0 && (
|
| 395 |
+
<>
|
| 396 |
+
<span className="kv-label">Headers</span>
|
| 397 |
+
<div className="kv-block" style={{ marginBottom: 8 }}>
|
| 398 |
+
{Object.entries(res.request.headers).map(([k, v]) => (
|
| 399 |
+
<div className="kv-row" key={k}><span className="k">{k}:</span><span className="v">{v}</span></div>
|
| 400 |
+
))}
|
| 401 |
+
</div>
|
| 402 |
+
</>
|
| 403 |
+
)}
|
| 404 |
+
{res.request.query_params && Object.keys(res.request.query_params).length > 0 && (
|
| 405 |
+
<>
|
| 406 |
+
<span className="kv-label">Query</span>
|
| 407 |
+
<div className="kv-block" style={{ marginBottom: 8 }}>
|
| 408 |
+
{Object.entries(res.request.query_params).map(([k, v]) => (
|
| 409 |
+
<div className="kv-row" key={k}><span className="k">{k}=</span><span className="v">{v}</span></div>
|
| 410 |
+
))}
|
| 411 |
+
</div>
|
| 412 |
+
</>
|
| 413 |
+
)}
|
| 414 |
+
{res.request.body != null && (
|
| 415 |
+
<>
|
| 416 |
+
<span className="kv-label">Body</span>
|
| 417 |
+
<pre className="code">{
|
| 418 |
+
typeof res.request.body === 'string'
|
| 419 |
+
? (() => { try { return JSON.stringify(JSON.parse(res.request.body), null, 2); } catch { return res.request.body; } })()
|
| 420 |
+
: JSON.stringify(res.request.body, null, 2)
|
| 421 |
+
}</pre>
|
| 422 |
+
</>
|
| 423 |
+
)}
|
| 424 |
+
{res.request.form_data && Object.keys(res.request.form_data).length > 0 && (
|
| 425 |
+
<>
|
| 426 |
+
<span className="kv-label">Form data</span>
|
| 427 |
+
<pre className="code">{JSON.stringify(res.request.form_data, null, 2)}</pre>
|
| 428 |
+
</>
|
| 429 |
+
)}
|
| 430 |
+
</div>
|
| 431 |
+
)}
|
| 432 |
+
</div>
|
| 433 |
+
|
| 434 |
+
<div>
|
| 435 |
+
<div className="rr-head"><span className="lbl">Response</span></div>
|
| 436 |
+
{!res.response ? (
|
| 437 |
+
<div style={{ fontSize: 11, color: 'var(--fg-3)', fontStyle: 'italic' }}>Waitingβ¦</div>
|
| 438 |
+
) : (
|
| 439 |
+
<pre className="code">{
|
| 440 |
+
(() => {
|
| 441 |
+
const body = res.response.body;
|
| 442 |
+
if (body == null || body === '') return '(empty)';
|
| 443 |
+
if (typeof body === 'object') {
|
| 444 |
+
try { return JSON.stringify(body, null, 2); } catch { return String(body); }
|
| 445 |
+
}
|
| 446 |
+
try { return JSON.stringify(JSON.parse(body), null, 2); } catch { return String(body); }
|
| 447 |
+
})()
|
| 448 |
+
}</pre>
|
| 449 |
+
)}
|
| 450 |
+
</div>
|
| 451 |
+
</div>
|
| 452 |
+
</div>
|
| 453 |
+
)}
|
| 454 |
+
</div>
|
| 455 |
+
);
|
| 456 |
+
})}
|
| 457 |
+
</div>
|
| 458 |
+
)}
|
| 459 |
+
|
| 460 |
+
{/* OTP modal */}
|
| 461 |
+
{otpPrompt && (
|
| 462 |
+
<div style={{ position: 'fixed', inset: 0, zIndex: 50, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(0,0,0,0.7)', backdropFilter: 'blur(8px)', padding: 16 }}>
|
| 463 |
+
<div style={{ background: 'var(--bg-1)', border: '1px solid var(--line-3)', borderRadius: 10, width: '100%', maxWidth: 420, overflow: 'hidden', boxShadow: 'var(--shadow-md)' }}>
|
| 464 |
+
<div style={{ padding: '12px 16px', borderBottom: '1px solid var(--line-1)', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
| 465 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
| 466 |
+
<Zap size={14} style={{ color: 'var(--accent)' }}/>
|
| 467 |
+
<span style={{ fontSize: 13, fontWeight: 600, color: 'var(--fg-0)' }}>Verification Required</span>
|
| 468 |
+
</div>
|
| 469 |
+
<button onClick={() => setOtpPrompt(null)} className="ico-btn"><X size={14}/></button>
|
| 470 |
+
</div>
|
| 471 |
+
<div style={{ padding: 20 }}>
|
| 472 |
+
<p style={{ fontSize: 12, color: 'var(--fg-2)', marginBottom: 14, lineHeight: 1.6 }}>
|
| 473 |
+
Enter the verification code to save it to your session context.
|
| 474 |
+
</p>
|
| 475 |
+
<span className="kv-label">Field: <span style={{ color: 'var(--accent)' }}>{otpPrompt.otpFieldName}</span></span>
|
| 476 |
+
<input
|
| 477 |
+
className="input"
|
| 478 |
+
autoFocus
|
| 479 |
+
placeholder="Enter codeβ¦"
|
| 480 |
+
value={otpInput}
|
| 481 |
+
onChange={e => setOtpInput(e.target.value)}
|
| 482 |
+
onKeyDown={e => { if (e.key === 'Enter') handleOtpSubmit(); }}
|
| 483 |
+
style={{ marginBottom: 12 }}
|
| 484 |
+
/>
|
| 485 |
+
<div style={{ display: 'flex', gap: 8 }}>
|
| 486 |
+
<button onClick={handleOtpSubmit} className="btn btn-primary" style={{ flex: 1 }}>Save & Continue</button>
|
| 487 |
+
<button onClick={() => setOtpPrompt(null)} className="btn">Cancel</button>
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
</div>
|
| 491 |
+
</div>
|
| 492 |
+
)}
|
| 493 |
+
|
| 494 |
+
{/* Selection modal */}
|
| 495 |
+
{selectionPrompt && (
|
| 496 |
+
<div style={{ position: 'fixed', inset: 0, zIndex: 50, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(0,0,0,0.7)', backdropFilter: 'blur(8px)', padding: 16 }}>
|
| 497 |
+
<div style={{ background: 'var(--bg-1)', border: '1px solid var(--line-3)', borderRadius: 10, width: '100%', maxWidth: 480, maxHeight: '80vh', overflow: 'hidden', display: 'flex', flexDirection: 'column', boxShadow: 'var(--shadow-md)' }}>
|
| 498 |
+
<div style={{ padding: '12px 16px', borderBottom: '1px solid var(--line-1)', display: 'flex', alignItems: 'center', justifyContent: 'space-between', flexShrink: 0 }}>
|
| 499 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
| 500 |
+
<Layers size={14} style={{ color: 'var(--accent)' }}/>
|
| 501 |
+
<span style={{ fontSize: 13, fontWeight: 600, color: 'var(--fg-0)' }}>Choose an Option</span>
|
| 502 |
+
</div>
|
| 503 |
+
<button onClick={() => setSelectionPrompt(null)} className="ico-btn"><X size={14}/></button>
|
| 504 |
+
</div>
|
| 505 |
+
<div style={{ padding: 20, overflowY: 'auto' }}>
|
| 506 |
+
<p style={{ fontSize: 12, color: 'var(--fg-2)', marginBottom: 14, lineHeight: 1.6 }}>
|
| 507 |
+
Select one to save as <code style={{ color: 'var(--accent)' }}>{selectionPrompt.fieldName}</code>.
|
| 508 |
+
</p>
|
| 509 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 14 }}>
|
| 510 |
+
{selectionPrompt.options.map((opt, idx) => (
|
| 511 |
+
<button
|
| 512 |
+
key={idx}
|
| 513 |
+
onClick={() => handleSelectionSubmit(opt)}
|
| 514 |
+
className="col-card"
|
| 515 |
+
style={{ textAlign: 'left', padding: '10px 14px', borderRadius: 6, cursor: 'pointer' }}
|
| 516 |
+
>
|
| 517 |
+
<div style={{ fontSize: 13, color: 'var(--fg-0)', fontWeight: 500, marginBottom: 2 }}>{opt.label || 'Option'}</div>
|
| 518 |
+
<div style={{ fontSize: 10.5, color: 'var(--fg-3)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
| 519 |
+
{typeof opt.value === 'object' ? JSON.stringify(opt.value) : String(opt.value)}
|
| 520 |
+
</div>
|
| 521 |
+
</button>
|
| 522 |
+
))}
|
| 523 |
+
</div>
|
| 524 |
+
{selectionPrompt.responseBody && (
|
| 525 |
+
<details style={{ cursor: 'pointer' }}>
|
| 526 |
+
<summary style={{ fontSize: 11, color: 'var(--fg-3)', display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }}>
|
| 527 |
+
<Code size={12}/> Raw response
|
| 528 |
+
</summary>
|
| 529 |
+
<pre className="code" style={{ maxHeight: 160 }}>
|
| 530 |
+
{(() => { try { return JSON.stringify(JSON.parse(selectionPrompt.responseBody), null, 2); } catch { return selectionPrompt.responseBody; } })()}
|
| 531 |
+
</pre>
|
| 532 |
+
</details>
|
| 533 |
+
)}
|
| 534 |
+
<button onClick={() => setSelectionPrompt(null)} className="btn" style={{ width: '100%', justifyContent: 'center', marginTop: 8 }}>
|
| 535 |
+
Cancel
|
| 536 |
+
</button>
|
| 537 |
+
</div>
|
| 538 |
+
</div>
|
| 539 |
+
</div>
|
| 540 |
+
)}
|
| 541 |
+
</div>
|
| 542 |
+
</div>
|
| 543 |
+
|
| 544 |
+
{/* Scenario composer β pinned to bottom */}
|
| 545 |
+
<div style={{ borderTop: '1px solid var(--line-1)', background: 'var(--bg-1)', flexShrink: 0 }}>
|
| 546 |
+
<div style={{ maxWidth: 900, margin: '0 auto', padding: '14px 32px' }}>
|
| 547 |
+
<div className="composer">
|
| 548 |
+
<div className="composer-head">
|
| 549 |
+
<span className="dot"/>
|
| 550 |
+
<span>scenario.txt</span>
|
| 551 |
+
{activeSpecName && activeSpecName !== 'None' && (
|
| 552 |
+
<><span style={{ color: 'var(--fg-4)' }}>Β·</span><span style={{ color: 'var(--fg-3)' }}>{activeSpecName}</span></>
|
| 553 |
+
)}
|
| 554 |
+
</div>
|
| 555 |
+
<textarea
|
| 556 |
+
rows={2}
|
| 557 |
+
placeholder={activeSpecId ? "Describe a test scenario, e.g. 'Sign in, create an order, charge it, verify paid'" : "Load a collection from the sidebar to begin"}
|
| 558 |
+
disabled={!activeSpecId || isPlanning}
|
| 559 |
+
value={scenario}
|
| 560 |
+
onChange={e => setScenario(e.target.value)}
|
| 561 |
+
onKeyDown={e => {
|
| 562 |
+
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
| 563 |
+
e.preventDefault();
|
| 564 |
+
handleGeneratePlan();
|
| 565 |
+
}
|
| 566 |
+
}}
|
| 567 |
+
/>
|
| 568 |
+
<div className="composer-foot">
|
| 569 |
+
<div className="hint">
|
| 570 |
+
<kbd>β</kbd><kbd>β΅</kbd> generate plan
|
| 571 |
+
</div>
|
| 572 |
+
<button className="btn btn-ghost" onClick={() => setScenario('')}>Clear</button>
|
| 573 |
+
<button
|
| 574 |
+
onClick={handleGeneratePlan}
|
| 575 |
+
disabled={!activeSpecId || isPlanning || !scenario.trim()}
|
| 576 |
+
className="btn btn-primary"
|
| 577 |
+
>
|
| 578 |
+
{isPlanning
|
| 579 |
+
? <><RefreshCw size={13} style={{ animation: 'spin 1s linear infinite' }}/> Planningβ¦</>
|
| 580 |
+
: <><Sparkles size={13}/> Generate plan</>}
|
| 581 |
+
</button>
|
| 582 |
+
</div>
|
| 583 |
+
</div>
|
| 584 |
+
</div>
|
| 585 |
+
</div>
|
| 586 |
+
</div>
|
| 587 |
+
|
| 588 |
+
{/* ββ Right context panel ββββββββββββββββββββββββββββββββ */}
|
| 589 |
+
<aside style={{
|
| 590 |
+
display: 'flex',
|
| 591 |
+
flexShrink: 0,
|
| 592 |
+
background: 'var(--bg-1)',
|
| 593 |
+
borderLeft: '1px solid var(--line-1)',
|
| 594 |
+
transition: 'width 280ms ease',
|
| 595 |
+
width: rightPanelOpen ? (rightPanelMode === 'chat' ? 360 : 300) : 0,
|
| 596 |
+
overflow: 'hidden',
|
| 597 |
+
}}>
|
| 598 |
+
<div style={{ width: rightPanelMode === 'chat' ? 360 : 300, height: '100%', display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
|
| 599 |
+
|
| 600 |
+
{/* Panel tab header */}
|
| 601 |
+
<div style={{ height: 48, display: 'flex', alignItems: 'center', borderBottom: '1px solid var(--line-1)', padding: '0 8px', gap: 4, flexShrink: 0 }}>
|
| 602 |
+
<div style={{ display: 'flex', flex: 1, background: 'var(--bg-2)', borderRadius: 4, padding: 2 }}>
|
| 603 |
+
<button
|
| 604 |
+
onClick={() => setRightPanelMode('context')}
|
| 605 |
+
style={{
|
| 606 |
+
flex: 1, padding: '4px 8px', borderRadius: 3, border: 0,
|
| 607 |
+
fontSize: 10.5, fontWeight: 600, letterSpacing: '0.08em', textTransform: 'uppercase',
|
| 608 |
+
background: rightPanelMode === 'context' ? 'var(--bg-0)' : 'transparent',
|
| 609 |
+
color: rightPanelMode === 'context' ? 'var(--fg-0)' : 'var(--fg-3)',
|
| 610 |
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 5,
|
| 611 |
+
transition: 'all 120ms', cursor: 'pointer',
|
| 612 |
+
}}
|
| 613 |
+
>
|
| 614 |
+
<Database size={10}/> Context
|
| 615 |
+
</button>
|
| 616 |
+
<button
|
| 617 |
+
onClick={() => setRightPanelMode('chat')}
|
| 618 |
+
style={{
|
| 619 |
+
flex: 1, padding: '4px 8px', borderRadius: 3, border: 0,
|
| 620 |
+
fontSize: 10.5, fontWeight: 600, letterSpacing: '0.08em', textTransform: 'uppercase',
|
| 621 |
+
background: rightPanelMode === 'chat' ? 'var(--bg-0)' : 'transparent',
|
| 622 |
+
color: rightPanelMode === 'chat' ? 'var(--accent)' : 'var(--fg-3)',
|
| 623 |
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 5,
|
| 624 |
+
transition: 'all 120ms', cursor: 'pointer',
|
| 625 |
+
}}
|
| 626 |
+
>
|
| 627 |
+
<Bot size={10}/> AI
|
| 628 |
+
</button>
|
| 629 |
+
</div>
|
| 630 |
+
<button onClick={() => setRightPanelOpen(false)} className="ico-btn" title="Collapse panel">
|
| 631 |
+
<ChevronRight size={14}/>
|
| 632 |
+
</button>
|
| 633 |
+
</div>
|
| 634 |
+
|
| 635 |
+
{/* Context panel */}
|
| 636 |
+
<div style={{ flex: 1, overflowY: 'auto', padding: 14, display: rightPanelMode === 'context' ? 'flex' : 'none', flexDirection: 'column', gap: 16 }}>
|
| 637 |
+
<section>
|
| 638 |
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 }}>
|
| 639 |
+
<span className="h-eyebrow">Session Variables</span>
|
| 640 |
+
<button onClick={refreshSessionContext} className="ico-btn" style={{ width: 22, height: 22 }} title="Refresh">
|
| 641 |
+
<RefreshCw size={11}/>
|
| 642 |
+
</button>
|
| 643 |
+
</div>
|
| 644 |
+
<div className="panel" style={{ overflow: 'hidden' }}>
|
| 645 |
+
{Object.keys(sessionContextVars || {}).length === 0 ? (
|
| 646 |
+
<div style={{ padding: 14, textAlign: 'center' }}>
|
| 647 |
+
<Circle size={18} style={{ margin: '0 auto 6px', color: 'var(--fg-4)', display: 'block' }} strokeWidth={1.5}/>
|
| 648 |
+
<p style={{ fontSize: 11, color: 'var(--fg-3)', margin: 0, fontStyle: 'italic' }}>No variables extracted</p>
|
| 649 |
+
</div>
|
| 650 |
+
) : (
|
| 651 |
+
Object.entries(sessionContextVars).map(([k, v]) => (
|
| 652 |
+
<div key={k} style={{ padding: '6px 12px', borderBottom: '1px solid var(--line-1)' }}>
|
| 653 |
+
<div style={{ fontSize: 10, fontWeight: 600, color: 'var(--accent)', marginBottom: 2 }}>{k}</div>
|
| 654 |
+
<div style={{ fontSize: 11, color: 'var(--fg-2)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{String(v)}</div>
|
| 655 |
+
</div>
|
| 656 |
+
))
|
| 657 |
+
)}
|
| 658 |
+
</div>
|
| 659 |
+
</section>
|
| 660 |
+
|
| 661 |
+
<section>
|
| 662 |
+
<div style={{ marginBottom: 8 }}>
|
| 663 |
+
<span className="h-eyebrow">Test Credentials</span>
|
| 664 |
+
</div>
|
| 665 |
+
<div className="panel" style={{ overflow: 'hidden' }}>
|
| 666 |
+
{Object.keys(storedCredentials || {}).length === 0 ? (
|
| 667 |
+
<div style={{ padding: 14, textAlign: 'center' }}>
|
| 668 |
+
<Circle size={18} style={{ margin: '0 auto 6px', color: 'var(--fg-4)', display: 'block' }} strokeWidth={1.5}/>
|
| 669 |
+
<p style={{ fontSize: 11, color: 'var(--fg-3)', margin: 0, fontStyle: 'italic' }}>No credentials loaded</p>
|
| 670 |
+
</div>
|
| 671 |
+
) : (
|
| 672 |
+
Object.entries(storedCredentials).filter(([k]) => k !== '_clear').map(([k, v]) => {
|
| 673 |
+
const isSensitive = k.toLowerCase().match(/(password|token|jwt|secret|bearer)/);
|
| 674 |
+
const display = isSensitive && v ? `${String(v).slice(0, 4)}β’β’β’β’` : String(v);
|
| 675 |
+
return (
|
| 676 |
+
<div key={k} style={{ padding: '6px 12px', borderBottom: '1px solid var(--line-1)' }}>
|
| 677 |
+
<div style={{ fontSize: 10, fontWeight: 600, color: 'var(--accent)', marginBottom: 2 }}>{k}</div>
|
| 678 |
+
<div style={{ fontSize: 11, color: 'var(--fg-2)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{display}</div>
|
| 679 |
+
</div>
|
| 680 |
+
);
|
| 681 |
+
})
|
| 682 |
+
)}
|
| 683 |
+
</div>
|
| 684 |
+
</section>
|
| 685 |
+
</div>
|
| 686 |
+
|
| 687 |
+
{/* Inline AI chat panel */}
|
| 688 |
+
<div style={{ flex: 1, minHeight: 0, overflow: 'hidden', display: rightPanelMode === 'chat' ? 'flex' : 'none', flexDirection: 'column' }}>
|
| 689 |
+
<ChatAssistant
|
| 690 |
+
compact={true}
|
| 691 |
+
allStepResultsProp={stepResults}
|
| 692 |
+
lastStepResultProp={
|
| 693 |
+
Object.keys(stepResults).length > 0
|
| 694 |
+
? stepResults[Math.max(...Object.keys(stepResults).map(Number))]
|
| 695 |
+
: null
|
| 696 |
+
}
|
| 697 |
+
executeStepFromChat={async (stepDef, changes) => {
|
| 698 |
+
const modifiedStep = changes && Object.keys(changes).length > 0
|
| 699 |
+
? {
|
| 700 |
+
...stepDef,
|
| 701 |
+
body: changes.body !== undefined ? { ...(stepDef.body || {}), ...changes.body } : stepDef.body,
|
| 702 |
+
query_params: changes.query_params !== undefined ? { ...(stepDef.query_params || {}), ...changes.query_params } : stepDef.query_params,
|
| 703 |
+
headers: changes.headers !== undefined ? { ...(stepDef.headers || {}), ...changes.headers } : stepDef.headers,
|
| 704 |
+
path_params: changes.path_params !== undefined ? { ...(stepDef.path_params || {}), ...changes.path_params } : stepDef.path_params,
|
| 705 |
+
...Object.fromEntries(Object.entries(changes).filter(([k]) => !['body', 'query_params', 'headers', 'path_params'].includes(k)))
|
| 706 |
+
}
|
| 707 |
+
: stepDef;
|
| 708 |
+
await executeStep(modifiedStep);
|
| 709 |
+
return {
|
| 710 |
+
step_definition: modifiedStep,
|
| 711 |
+
response: stepResults[modifiedStep.step]?.response,
|
| 712 |
+
analysis: stepResults[modifiedStep.step]?.analysis,
|
| 713 |
+
};
|
| 714 |
+
}}
|
| 715 |
+
/>
|
| 716 |
+
</div>
|
| 717 |
+
</div>
|
| 718 |
+
</aside>
|
| 719 |
+
|
| 720 |
+
{/* Expand button when panel is collapsed */}
|
| 721 |
+
{!rightPanelOpen && (
|
| 722 |
+
<button
|
| 723 |
+
onClick={() => setRightPanelOpen(true)}
|
| 724 |
+
style={{
|
| 725 |
+
position: 'absolute', right: 0, top: '50%', transform: 'translateY(-50%)',
|
| 726 |
+
zIndex: 20, padding: '6px 4px',
|
| 727 |
+
background: 'var(--bg-1)', color: 'var(--fg-2)',
|
| 728 |
+
border: '1px solid var(--line-2)', borderRight: 0,
|
| 729 |
+
borderRadius: '4px 0 0 4px',
|
| 730 |
+
transition: 'color 120ms', cursor: 'pointer',
|
| 731 |
+
}}
|
| 732 |
+
title="Open context panel"
|
| 733 |
+
>
|
| 734 |
+
<ChevronRight size={14} style={{ transform: 'rotate(180deg)' }}/>
|
| 735 |
+
</button>
|
| 736 |
+
)}
|
| 737 |
+
</div>
|
| 738 |
+
);
|
| 739 |
+
}
|
requirements.txt
CHANGED
|
@@ -17,6 +17,8 @@ prance>=0.21.0
|
|
| 17 |
pyyaml>=6.0
|
| 18 |
slowapi>=0.1.9
|
| 19 |
cryptography>=42.0.0
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Testing
|
| 22 |
pytest>=8.0.0
|
|
|
|
| 17 |
pyyaml>=6.0
|
| 18 |
slowapi>=0.1.9
|
| 19 |
cryptography>=42.0.0
|
| 20 |
+
alembic>=1.13.0
|
| 21 |
+
filetype>=1.2.0
|
| 22 |
|
| 23 |
# Testing
|
| 24 |
pytest>=8.0.0
|