Commit 57aeafe
feat(playground): add Chat UI and comparison testing (#74)
* style: apply code formatter
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(playground): add database schema, migrations, and queries
Add 5 new tables for the playground feature:
- playground_conversations: chat conversations with model/params
- playground_messages: individual messages in conversations
- playground_test_cases: reusable test case templates
- playground_test_runs: test run executions across models
- playground_test_results: per-model results with metrics
Includes CRUD query functions and Drizzle migration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(playground): add backend admin API endpoints
Add REST endpoints for playground resources under /api/admin/playground:
- Conversations: CRUD + message management
- Test cases: CRUD with message templates
- Test runs: create/list/delete with per-model results
- Test results: update status, response, and metrics
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(playground): add frontend chat and comparison testing UI
Add a new "Playground" section with two tabs:
Chat tab:
- Three-pane layout: conversation list, chat area, parameter sidebar
- Model and API key selection via dropdowns
- Real-time streaming responses via SSE
- Conversation persistence with auto-generated titles
- Configurable parameters: system prompt, temperature, top_p, etc.
Compare tab:
- Create reusable test cases with message templates
- Run test cases against multiple models simultaneously
- Side-by-side comparison of responses with metrics (tokens, TTFT, duration)
Also adds shadcn/ui components (scroll-area, slider, textarea),
i18n keys for both en-US and zh-CN, and sidebar navigation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(playground): address code review feedback
Backend:
- Extract shared roleSchema for consistent role validation
- Return 404 when test result not found (was returning 200 null)
- Return 500 status on test run creation failure (was returning 200)
- Add pagination limit upper bound (max 200)
Frontend:
- Fix stopSequences input UX: normalize on blur instead of every keystroke
- Abort previous stream before starting new one in useChatStreaming
- Use functional updater in handleSend to avoid stale closure
- Add try/catch error handling to handleSend, handleSaveAsTestCase,
handleCreate, handleDelete, handleUpdate
- Use instant scroll during streaming, smooth scroll otherwise
- Forward all supported params in comparison test runs
- Fix test-case-editor to include params in save payload
- Replace hard-coded English labels with i18n keys
- Fix NavContent anti-pattern (function call instead of component)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(playground): address follow-up code review feedback
- Add null checks for conversation and test case creation (500 on failure)
- Add try/catch for conversation creation in chat handleSend
- Add try/catch for assistant message persistence in onDone
- Move sendMessage side effect out of setMessages state updater
- Add toast for test run creation failure
- Add nested try/catch for PUT in comparison catch block
- Add missing `t` and `messages` to useCallback dependencies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(playground): add FK cascade/set-null actions and atomic test run creation
Add proper ON DELETE actions to playground FK constraints:
- CASCADE for parent-child relationships (messages, test runs, results)
- SET NULL for nullable external references (api keys, completions)
Wrap test run + result creation in a database transaction for atomicity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(playground): add message insert null check, TTFT translation, and outer catch
- Add null check with 500 status for insertPlaygroundMessage POST handler
- Fix TTFT zh-CN translation to match existing terminology (首 Token 返回时间)
- Add catch block to handleRunComparison outer try for user error feedback
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(playground): validate testCaseId, fail transaction on insert error, fix running PUT scope
- Validate testCaseId exists before creating test run (404 if not found)
- Throw error in transaction when result insert fails instead of silently skipping
- Move running status PUT inside inner try block so failures are properly caught
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 454e721 commit 57aeafe
84 files changed
Lines changed: 7467 additions & 1654 deletions
File tree
- backend
- drizzle
- meta
- src
- adapters
- upstream
- api
- admin
- v1
- db
- search
- __tests__
- services
- utils
- frontend/src
- components
- app
- ui
- hooks
- i18n/locales
- lib
- kql
- pages
- overview
- playground
- chat
- compare
- requests
- search
- settings
- routes
- playground
- chat
- compare
- requests
- settings
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 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 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 95 | + | |
98 | 96 | | |
99 | 97 | | |
100 | 98 | | |
| |||
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 225 | + | |
| 226 | + | |
233 | 227 | | |
234 | 228 | | |
235 | 229 | | |
236 | 230 | | |
237 | 231 | | |
238 | 232 | | |
239 | 233 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 234 | + | |
| 235 | + | |
246 | 236 | | |
247 | 237 | | |
248 | 238 | | |
| |||
252 | 242 | | |
253 | 243 | | |
254 | 244 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 245 | + | |
258 | 246 | | |
259 | 247 | | |
260 | 248 | | |
| |||
366 | 354 | | |
367 | 355 | | |
368 | 356 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 357 | + | |
| 358 | + | |
375 | 359 | | |
376 | 360 | | |
377 | 361 | | |
378 | 362 | | |
379 | 363 | | |
380 | 364 | | |
381 | 365 | | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 366 | + | |
| 367 | + | |
388 | 368 | | |
389 | 369 | | |
390 | 370 | | |
| |||
394 | 374 | | |
395 | 375 | | |
396 | 376 | | |
397 | | - | |
398 | | - | |
399 | | - | |
| 377 | + | |
400 | 378 | | |
401 | 379 | | |
402 | 380 | | |
| |||
509 | 487 | | |
510 | 488 | | |
511 | 489 | | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
| 490 | + | |
| 491 | + | |
518 | 492 | | |
519 | 493 | | |
520 | 494 | | |
| |||
524 | 498 | | |
525 | 499 | | |
526 | 500 | | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 501 | + | |
531 | 502 | | |
532 | 503 | | |
533 | 504 | | |
| |||
622 | 593 | | |
623 | 594 | | |
624 | 595 | | |
625 | | - | |
626 | | - | |
627 | | - | |
| 596 | + | |
628 | 597 | | |
629 | 598 | | |
630 | 599 | | |
| |||
679 | 648 | | |
680 | 649 | | |
681 | 650 | | |
682 | | - | |
683 | | - | |
684 | | - | |
| 651 | + | |
685 | 652 | | |
686 | 653 | | |
687 | 654 | | |
| |||
773 | 740 | | |
774 | 741 | | |
775 | 742 | | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
| 743 | + | |
| 744 | + | |
782 | 745 | | |
783 | 746 | | |
784 | 747 | | |
785 | 748 | | |
786 | 749 | | |
787 | 750 | | |
788 | 751 | | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
| 752 | + | |
| 753 | + | |
795 | 754 | | |
796 | 755 | | |
797 | 756 | | |
798 | 757 | | |
799 | 758 | | |
800 | 759 | | |
801 | 760 | | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
| 761 | + | |
| 762 | + | |
808 | 763 | | |
809 | 764 | | |
810 | 765 | | |
| |||
814 | 769 | | |
815 | 770 | | |
816 | 771 | | |
817 | | - | |
818 | | - | |
819 | | - | |
| 772 | + | |
820 | 773 | | |
821 | 774 | | |
822 | 775 | | |
| |||
922 | 875 | | |
923 | 876 | | |
924 | 877 | | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
| 878 | + | |
930 | 879 | | |
931 | 880 | | |
932 | 881 | | |
933 | 882 | | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
| 883 | + | |
938 | 884 | | |
939 | 885 | | |
940 | 886 | | |
941 | 887 | | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
| 888 | + | |
949 | 889 | | |
950 | 890 | | |
951 | 891 | | |
952 | 892 | | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
| 893 | + | |
959 | 894 | | |
960 | 895 | | |
961 | 896 | | |
| |||
968 | 903 | | |
969 | 904 | | |
970 | 905 | | |
971 | | - | |
| 906 | + | |
0 commit comments