From 7ef0228e8abe03c80098dce1866a16309a972126 Mon Sep 17 00:00:00 2001 From: psmyrdek Date: Wed, 20 Aug 2025 13:44:59 +0200 Subject: [PATCH 1/8] feat: avatar --- src/components/Avatar.tsx | 19 +++++++++++++++++++ src/components/ChatMessage.tsx | 10 ++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/components/Avatar.tsx diff --git a/src/components/Avatar.tsx b/src/components/Avatar.tsx new file mode 100644 index 0000000..cd04862 --- /dev/null +++ b/src/components/Avatar.tsx @@ -0,0 +1,19 @@ +import {User, Bot} from "lucide-react"; + +interface AvatarProps { + role: "user" | "assistant"; +} + +export default function Avatar({ role }: AvatarProps) { + const isUser = role === "user"; + + return ( +
+ {isUser ? : } +
+ ); +} \ No newline at end of file diff --git a/src/components/ChatMessage.tsx b/src/components/ChatMessage.tsx index 83fe393..db77032 100644 --- a/src/components/ChatMessage.tsx +++ b/src/components/ChatMessage.tsx @@ -1,4 +1,4 @@ -import {User, Bot} from "lucide-react"; +import Avatar from "./Avatar"; interface ChatMessageProps { content: string; @@ -19,13 +19,7 @@ export default function ChatMessage({ } gap-3`} > {/* Avatar */} -
- {isUser ? : } -
+ {/* Message bubble */}
Date: Wed, 20 Aug 2025 13:48:38 +0200 Subject: [PATCH 2/8] feat: refactor --- .ai/prompts/code-review-fix.md | 1 + .github/workflows/pull-request-fix.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .ai/prompts/code-review-fix.md diff --git a/.ai/prompts/code-review-fix.md b/.ai/prompts/code-review-fix.md new file mode 100644 index 0000000..2033d5c --- /dev/null +++ b/.ai/prompts/code-review-fix.md @@ -0,0 +1 @@ +Jesteś senior developerem Astro, TypeScript i React, który wdraża zmiany wskazane w trakcie Code Review. Priorytetowo traktujesz krytyczne błędy i obiektywne uwagi od komentujących, ignorując detale i subiektywne opinie. Twoja praca skupia się wyłącznie na zakresie wskazanym w komentarzu. \ No newline at end of file diff --git a/.github/workflows/pull-request-fix.yml b/.github/workflows/pull-request-fix.yml index 55c6ad2..5532e72 100644 --- a/.github/workflows/pull-request-fix.yml +++ b/.github/workflows/pull-request-fix.yml @@ -75,7 +75,8 @@ jobs: CLAUDE_PROMPT: ${{ steps.fetch_bot_comment.outputs.result }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | - claude --append-system-prompt "You are a senior developer fixing code in a pull request. You are given a comment from a Code Review session and you need to fix the code based on the comment." \ + CLAUDE_CR_PROMPT=$(cat .ai/prompts/code-review-fix.md) + claude --append-system-prompt "$CLAUDE_CR_PROMPT" \ --print "$CLAUDE_PROMPT" - name: Detect changes From eb012ec62c36c494c20619f929990323c278e001 Mon Sep 17 00:00:00 2001 From: psmyrdek Date: Wed, 20 Aug 2025 13:51:04 +0200 Subject: [PATCH 3/8] feat: ocena --- .ai/prompts/code-review.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.ai/prompts/code-review.md b/.ai/prompts/code-review.md index 00d764d..aefe8c9 100644 --- a/.ai/prompts/code-review.md +++ b/.ai/prompts/code-review.md @@ -2,11 +2,18 @@ Jesteś doświadczonym starszym programistą przeprowadzającym kompleksowe Code Review dla aplikacji Astro korzystającej z komponentów React i styli Tailwind CSS. -WAŻNE: Twoim zadaniem jest Code Review i dostarczenie opinii na temat zmian w kodzie. +Twoim zadaniem jest Code Review i dostarczenie opinii na temat zmian w kodzie. + +Na podstawie dostarczonej zawartości różnic, przeanalizuj zmiany w kodzie i dostarcz szczegółową opinię opartą na następujących kryteriach: Jeśli nie ma żadnych zmian, napisz "Brak zmian do przeglądu". -Na podstawie dostarczonej zawartości różnic, przeanalizuj zmiany w kodzie i dostarcz szczegółową opinię opartą na następujących kryteriach: +Po dostarczeniu opinii, każdy Pull Request kończysz jedną z ocen: + +OCENA ZMIAN: +- ✅ Akceptacja +- 👮‍♂️ Upomnienie +- ❌ Wymagane zmiany ### Nowoczesne Wzorce React 18/19 i Architektura @@ -79,4 +86,3 @@ Na podstawie dostarczonej zawartości różnic, przeanalizuj zmiany w kodzie i d - ✅ Narzędzia testowe dla wspólnych wzorców (dostawcy, aterapy) - ❌ Komponenty mocno sprzężone z zewnętrznymi zależnościami - ❌ Brakujące atrybuty data-testid dla złożonych interakcji UI - From e9a1fa56e1257b1f9b06393b6ded126844151af4 Mon Sep 17 00:00:00 2001 From: psmyrdek Date: Wed, 20 Aug 2025 13:54:32 +0200 Subject: [PATCH 4/8] feat: cr criteria update --- .ai/prompts/code-review.md | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/.ai/prompts/code-review.md b/.ai/prompts/code-review.md index aefe8c9..13eae99 100644 --- a/.ai/prompts/code-review.md +++ b/.ai/prompts/code-review.md @@ -86,3 +86,49 @@ OCENA ZMIAN: - ✅ Narzędzia testowe dla wspólnych wzorców (dostawcy, aterapy) - ❌ Komponenty mocno sprzężone z zewnętrznymi zależnościami - ❌ Brakujące atrybuty data-testid dla złożonych interakcji UI + +### TypeScript + +#### 1. **Typy dla React Komponentów w Zmianach** +- ✅ Nowe komponenty używają precyzyjnych prop interfaces zamiast inline typów +- ✅ Dodane `React.FC` lub funkcyjne typy komponentów +- ✅ Właściwe użycie `children?: React.ReactNode` w komponentach kontenerowych +- ✅ Discriminated unions dla wariantów komponentów w nowych zmianach +- ❌ Dodawanie komponentów bez typowania props +- ❌ Używanie `any` w nowo dodanych component props + +#### 2. **Event Handlers i DOM Types w Kodzie** +- ✅ Precyzyjne typy eventów w nowych handlerach (`React.MouseEvent`) +- ✅ Właściwe typy dla refs w dodanych komponentach (`React.RefObject`) +- ✅ Forward refs z correct typing w nowych komponentach +- ❌ Event handlery bez typowania lub z `any` +- ❌ Refs bez właściwych DOM element types + +#### 3. **Custom Hooks TypeScript Patterns** +- ✅ Nowe custom hooks mają jasne return types i parameter types +- ✅ `useState` z explicit generic gdy Stan może być null/undefined +- ✅ Typed dependency arrays w `useEffect`, `useMemo`, `useCallback` +- ❌ Custom hooks bez return type annotations +- ❌ Dependency arrays z brakującymi lub nieprecyzyjnymi typami + +#### 4. **API Integration Types** +- ✅ Response/Request interfaces dla nowych API calls +- ✅ Error handling z typed error objects +- ✅ Loading states wykorzystujące discriminated unions +- ❌ API responses bez type validation +- ❌ Fetch calls z `any` response types + +#### 5. **TypeScript Best Practices w Zmianach** +- ✅ Konsekwentne użycie `import type` dla type-only importów +- ✅ Utility types (`Partial`, `Pick`) zamiast manual type definitions +- ✅ Template literal types dla string unions gdy potrzebne +- ✅ `as const` assertions dla immutable data +- ❌ Nadużywanie `any` lub type assertions `as` +- ❌ Nadmiernie skomplikowane typy bez business justification + +#### 6. **Form i Input Handling Types** +- ✅ Proper form event types (`React.FormEvent`) +- ✅ Input change events z correct target types +- ✅ Form validation schemas z type inference (Zod/Yup) +- ❌ Form handlers bez event typing +- ❌ Input values bez proper string/number type handling From eabbcfb84f4cf3db3161f1ee942fdb54238159a6 Mon Sep 17 00:00:00 2001 From: psmyrdek Date: Wed, 20 Aug 2025 17:34:30 +0200 Subject: [PATCH 5/8] feat: allow edits --- .github/workflows/pull-request-fix.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-fix.yml b/.github/workflows/pull-request-fix.yml index 5532e72..386e1ea 100644 --- a/.github/workflows/pull-request-fix.yml +++ b/.github/workflows/pull-request-fix.yml @@ -77,7 +77,8 @@ jobs: run: | CLAUDE_CR_PROMPT=$(cat .ai/prompts/code-review-fix.md) claude --append-system-prompt "$CLAUDE_CR_PROMPT" \ - --print "$CLAUDE_PROMPT" + --print "$CLAUDE_PROMPT" \ + --permission-mode "acceptEdits" - name: Detect changes id: detect_changes From 1d846ed931d424a3f511704500023052e0eeddc9 Mon Sep 17 00:00:00 2001 From: psmyrdek Date: Wed, 20 Aug 2025 17:39:09 +0200 Subject: [PATCH 6/8] feat: bump support --- .ai/prompts/code-review-fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ai/prompts/code-review-fix.md b/.ai/prompts/code-review-fix.md index 2033d5c..fd42a97 100644 --- a/.ai/prompts/code-review-fix.md +++ b/.ai/prompts/code-review-fix.md @@ -1 +1 @@ -Jesteś senior developerem Astro, TypeScript i React, który wdraża zmiany wskazane w trakcie Code Review. Priorytetowo traktujesz krytyczne błędy i obiektywne uwagi od komentujących, ignorując detale i subiektywne opinie. Twoja praca skupia się wyłącznie na zakresie wskazanym w komentarzu. \ No newline at end of file +Jesteś senior developerem Astro, TypeScript i React, który wdraża zmiany wskazane w trakcie Code Review. Twoja praca skupia się wyłącznie na zakresie wskazanym w komentarzu. Zaimplementuj te sugestie, co do których nie ma wątpliwości odnośnie wartości dla użytkownika końcowego. \ No newline at end of file From 2e8afb1807753c492ba52be5fcab4b48f463a2a1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:04:01 +0000 Subject: [PATCH 7/8] chore: apply Claude suggestions --- src/components/Avatar.tsx | 6 ++---- src/components/ChatMessage.tsx | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/Avatar.tsx b/src/components/Avatar.tsx index cd04862..fc7792c 100644 --- a/src/components/Avatar.tsx +++ b/src/components/Avatar.tsx @@ -1,12 +1,10 @@ import {User, Bot} from "lucide-react"; interface AvatarProps { - role: "user" | "assistant"; + isUser: boolean; } -export default function Avatar({ role }: AvatarProps) { - const isUser = role === "user"; - +export default function Avatar({ isUser }: AvatarProps) { return (
{/* Avatar */} - + {/* Message bubble */}
Date: Wed, 20 Aug 2025 18:13:03 +0200 Subject: [PATCH 8/8] feat: add suggestion categories for code review --- .ai/prompts/code-review.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.ai/prompts/code-review.md b/.ai/prompts/code-review.md index 13eae99..de1291c 100644 --- a/.ai/prompts/code-review.md +++ b/.ai/prompts/code-review.md @@ -15,6 +15,36 @@ OCENA ZMIAN: - 👮‍♂️ Upomnienie - ❌ Wymagane zmiany +## Kategorie sugestii + +Podczas przeprowadzania Code Review klasyfikuj swoje uwagi w trzy kategorie: + +### 🚫 BLOCKERY +- Krytyczne błędy bezpieczeństwa (XSS, SQL injection, CSRF) +- Poważne problemy wydajnościowe powodujące znaczne spowolnienia +- Błędy logiczne mogące prowadzić do utraty danych lub crash aplikacji +- Naruszenia kluczowych wzorców architektonicznych +- Brakujące granice błędów w krytycznych komponentach +- Potencjalne memory leaks lub nieskończone pętle + +### ⚠️ MAJORY +- Problemy z dostępnością (WCAG violations) +- Nieprawidłowe zarządzanie stanem globalnym +- Brakujące error handling +- Problemy z TypeScript safety (nadużywanie any, missing types) +- Niespójności z established code patterns +- Problemy wydajnościowe w komponentach kluczowych +- Brakujące testy dla nowej funkcjonalności + +### 📝 MINORY +- Sugestie dotyczące czytelności kodu +- Możliwości refactoringu dla lepszej maintainability +- Optymalizacje wydajnościowe w mniej krytycznych obszarach +- Ulepszenia w nazewnictwie zmiennych/funkcji +- Dodatkowe edge cases w testach +- Dokumentacja kodu (JSDoc comments) +- Formatting i style inconsistencies + ### Nowoczesne Wzorce React 18/19 i Architektura #### 1. **Implementacja Concurrent Features**