Swagger Editor App - #61
Conversation
* feat: install next+ts+linter+prettier+ husky+redux * feat: configs + perfectionist + lint fix * feat: install scss * refactor: add some folders * feat: add commitlint and remove default favicons * feat: delete unnecessary files --------- Co-authored-by: Yulia Demir <Nightelfin91@gmail.com>
This reverts commit 4b079b1.
* Merge pull request #39 from AlyaEngineer/story/0-development-environment feature/0 - Project setup * Chore: Set up testing environment (#47) * chore: set up testing environment with Vitest and RTL * style: satisfy eslint rule in commitlint config * fix: fix next build errors (#52) * chore: replace scss with css modules * chore: add placeholder for locale page and layout * сhore: apply lint formatting to config file
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds repository tooling, locale and theme wiring, shared navigation and error UI, Supabase authentication flows, and a Swagger editor with schema parsing, validation, persistence, and tests. ChangesApplication foundation and shared UI
Authentication
Swagger editor
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
tsconfig.json (1)
21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant path alias.
@/*already resolves to./src/*, so@/componentswould already work without a separate@componentsalias. Consider dropping the redundant entry for consistency.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tsconfig.json` around lines 21 - 24, The tsconfig paths mapping contains a redundant alias: `@components` duplicates the existing `@/*` resolution to `./src/*`, so remove the extra entry from the `paths` block and keep the shared `@/*` alias consistent for imports such as `@/components`.src/app/layout.tsx (1)
17-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePlaceholder metadata left unchanged.
title/descriptionstill reflect the defaultcreate-next-appscaffold rather than the "Swagger Editor" project. Low priority for a scaffolding PR, but should be updated before this becomes user-facing.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/layout.tsx` around lines 17 - 20, Update the exported metadata in layout.tsx so it no longer uses the default create-next-app placeholder values. Change the Metadata object in the metadata export to use project-specific title and description for Swagger Editor, keeping the update localized to the metadata definition.src/app/page.module.css (1)
21-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDead CSS: several classes are unused.
page.tsxonly referencesstyles.page, so.main,.intro,.ctas,a.primary/a.secondary, and.logo(referenced in the dark-mode block at line 127 but never defined) are all leftover from thecreate-next-appboilerplate and currently unused. Consider trimming this file to just what's rendered, or removing it once the real Home page is implemented.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/page.module.css` around lines 21 - 142, The page.module.css stylesheet still contains leftover create-next-app boilerplate that is not referenced by page.tsx, so remove the unused rules for .main, .intro, .ctas, a.primary, a.secondary, and the .logo dark-mode override, and keep only the styles actually applied by styles.page. If the Home page is intended to use these selectors later, move them into the component that renders them instead of leaving dead CSS in page.module.css.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 1-36: The README is still using the default create-next-app
guidance, which points to the wrong app location and misses this project’s
Swagger Editor/RS School context. Update the getting-started and overview text
to reference the actual app entry under src/app and replace the generic Next.js
template copy with repo-specific setup and usage notes, keeping the README
aligned with the current structure and purpose.
---
Nitpick comments:
In `@src/app/layout.tsx`:
- Around line 17-20: Update the exported metadata in layout.tsx so it no longer
uses the default create-next-app placeholder values. Change the Metadata object
in the metadata export to use project-specific title and description for Swagger
Editor, keeping the update localized to the metadata definition.
In `@src/app/page.module.css`:
- Around line 21-142: The page.module.css stylesheet still contains leftover
create-next-app boilerplate that is not referenced by page.tsx, so remove the
unused rules for .main, .intro, .ctas, a.primary, a.secondary, and the .logo
dark-mode override, and keep only the styles actually applied by styles.page. If
the Home page is intended to use these selectors later, move them into the
component that renders them instead of leaving dead CSS in page.module.css.
In `@tsconfig.json`:
- Around line 21-24: The tsconfig paths mapping contains a redundant alias:
`@components` duplicates the existing `@/*` resolution to `./src/*`, so remove
the extra entry from the `paths` block and keep the shared `@/*` alias
consistent for imports such as `@/components`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 783b7bb0-0fec-4d88-830e-64e58a7cf262
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (22)
.coderabbit.yaml.github/PULL_REQUEST_TEMPLATE.md.gitignore.husky/commit-msg.husky/pre-commit.prettierignore.prettierrcREADME.mdcommitlint.config.mjseslint.config.mjsnext.config.tspackage.jsonsrc/app/[locale]/layout.tsxsrc/app/[locale]/page.tsxsrc/app/globals.csssrc/app/layout.tsxsrc/app/page.module.csssrc/app/page.tsxsrc/components/index.tstsconfig.jsonvitest.config.tsvitest.setup.ts
* Story/1 sticky header general (#50) * feat: install next+ts+linter+prettier+ husky+redux * feat: configs + perfectionist + lint fix * feat: install scss * refactor: add some folders * feat: install i18n + basic configs * feat: add internatiolisation * feat: language switcher * feat: dependencies update * feat: add sticky header * feat: add mui Button-and-Link-like component * fix: lint * style: add style for header * refactor: remove css from language selector * refactor: add const for flex styles in the header boxes * refactor: history style as link * fix: add some fixes * feat: footer with about page link (#59) * feat: add Inter and JetBrains Mono fonts via next/font * feat: reorganize theme into palette, components, typography, theme modules * feat: add i18n translations for header navigation links * fix: prevent header layout shift on language switcher toggle click * feat: add footer with translated links and styling * test: add tests for footer * fix: correct invalid box-shadow offset * fix: fix header height * fix: fix language switcher * refactor: extract routes and external links into constants * refactor: remove leftover placeholder before merge * fix: add InitColorSchemeScript to prevent SSR flash * style: apply Prettier formatting --------- Co-authored-by: YuliaDemir <129578495+YuliaDemir@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/i18n/messages/en.json (1)
2-21: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueInconsistent namespace key casing.
Metadata,Header, andHomePageare PascalCase whilefooteris lowercase. Standardize casing across namespaces to avoid confusion when components reference translation keys (e.g.useTranslations('footer')vsuseTranslations('Footer')).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/i18n/messages/en.json` around lines 2 - 21, The translation namespace keys in the messages file are inconsistent because Metadata, Header, and HomePage use PascalCase while footer uses lowercase. Update the namespace key in the messages object to match the same casing convention used by the other sections, and make sure any references in components or hooks like useTranslations(...) use that same symbol consistently.src/app/[locale]/page.tsx (1)
1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueInconsistent import path for
FootervsHeader.
Headeris imported from the barrel@components, butFooterbypasses it and imports directly from its file. Use the barrel consistently for both.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/`[locale]/page.tsx around lines 1 - 4, The import style is inconsistent between Header and Footer in this page component. Update the Footer import to use the same barrel entry as Header from `@components` so both symbols are imported consistently, and keep the existing getTranslations import unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/auth-navigation/auth-navigation.tsx`:
- Around line 12-16: Remove the commented-out useAuth() call in
auth-navigation.tsx and replace the dead code with a concise TODO comment that
points to the tracked auth work; keep the current stub or replace it later, but
do not leave commented-out hook code inline. Use the auth-navigation component’s
useAuth-related destructuring as the location to clean up the dead code.
In `@src/i18n/messages/en.json`:
- Line 22: Remove the leftover debug translation entry from the English messages
file. The stray "check" key in the messages object appears to be a test
artifact, so delete it from the JSON alongside any related cleanup in the same
messages structure to keep the production i18n catalog clean.
In `@src/theme/components.ts`:
- Around line 54-68: The Select root styles in components.ts let the hover rule
override the focused outline because both selectors have equal specificity and
the hover rule comes later. Update the root style block so the focused state in
the root callback keeps precedence over hover, either by moving the focused
selector after the hover selector or by making the focused selector more
specific, ensuring the Mui-focused borderColor and borderWidth remain visible
when hovered.
---
Nitpick comments:
In `@src/app/`[locale]/page.tsx:
- Around line 1-4: The import style is inconsistent between Header and Footer in
this page component. Update the Footer import to use the same barrel entry as
Header from `@components` so both symbols are imported consistently, and keep the
existing getTranslations import unchanged.
In `@src/i18n/messages/en.json`:
- Around line 2-21: The translation namespace keys in the messages file are
inconsistent because Metadata, Header, and HomePage use PascalCase while footer
uses lowercase. Update the namespace key in the messages object to match the
same casing convention used by the other sections, and make sure any references
in components or hooks like useTranslations(...) use that same symbol
consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c3165677-59dd-4a0b-8ae2-81069c997260
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (28)
.coderabbit.yamlnext.config.tspackage.jsonsrc/app/[locale]/layout.tsxsrc/app/[locale]/page.tsxsrc/app/globals.csssrc/components/app-link/app-link.tsxsrc/components/auth-navigation/auth-navigation.tsxsrc/components/footer/footer.test.tsxsrc/components/footer/footer.tsxsrc/components/header/header.tsxsrc/components/index.tssrc/components/language-switcher/language-switcher.tsxsrc/constants/brand.tssrc/constants/routes.tssrc/fonts.tssrc/i18n/messages/en.jsonsrc/i18n/messages/ru.jsonsrc/i18n/navigation.tssrc/i18n/request.tssrc/i18n/routing.tssrc/providers/mui-provider.tsxsrc/proxy.tssrc/theme/components.tssrc/theme/index.tssrc/theme/palette.tssrc/theme/theme.tssrc/theme/typography.ts
✅ Files skipped from review due to trivial changes (5)
- src/i18n/routing.ts
- src/components/footer/footer.tsx
- src/constants/routes.ts
- src/components/index.ts
- src/i18n/messages/ru.json
🚧 Files skipped from review as they are similar to previous changes (1)
- .coderabbit.yaml
* feat: language switching (#53) * feat: install next+ts+linter+prettier+ husky+redux * feat: configs + perfectionist + lint fix * feat: install scss * refactor: add some folders * feat: install i18n + basic configs * feat: add internatiolisation * feat: language switcher * feat: dependencies update * fix: delete scss + delete unnecessary files * fix: delete unnecessary layout * feat: user friendly errors (#58) * feat: add error page component * test: add tests for error page component * feat: add global error page component * test: add tests for global error page component * feat: implement toast provider and toast component * test: add tests for toast provider and toast component * feat: add toaster messages dictionary * chore: add coderabbit config * fix: fix .coderabbit.yaml instruction * fix: add target branches for review to instructions * fix: move console.error into useEffect * fix: ignore clickaway on close * test: add test for onClose on clickaway * fix: memoize showToast and context value with useCallback/useMemo * fix: remove duplicate dependency entries from devDependencies in package.json * fix: pass showToast function directly to context instead of memoized object wrapper * fix: split combined toast state into three separate useState calls * refactor: extract error page props into named Props type * fix: fixes with Prettier * feat: integrate ToastProvider into app layout * refactor: extract shared ErrorCard component and align with MUI theme * refactor: rename ErrorCard props * fix: add suppressHydrationWarning to html tag to prevent expected mismatch * refactor: move Header and Footer into root layout * fix: wrap main content in semantic main element * fix: add borderBottom to AppBar in header --------- Co-authored-by: YuliaDemir <129578495+YuliaDemir@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/app/global-error.tsx (1)
36-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winHardcoded copy duplicates
errorPagetranslation strings.
"Something went wrong","Try refreshing the page or come back later", and"Try again"mirror theerrorPagemessages exercised inerror.test.tsx(title/description/retry). Sinceglobal-error.tsxrenders outside the locale layout it can't usenext-intl, but leaving the fallback copy as inline literals means the two content sources can silently drift if one is edited and not the other. Consider extracting these fallback strings into a small shared constant (e.g.src/constants/error-fallback.ts) imported by both this file and used as theendefault, so there's one place to update.As per path instructions, "Flag duplicate implementations of the same logic in different files."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/global-error.tsx` around lines 36 - 40, The fallback copy in global-error.tsx duplicates the errorPage text used elsewhere, so it can drift if edited separately. Extract the title, description, and retry label into a shared constant (for example, a small error-fallback module) and import it here and wherever the English default is defined, keeping the single source of truth aligned with errorPage and error.test.tsx.Source: Path instructions
src/app/[locale]/error.tsx (1)
14-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate error-logging effect shared with
global-error.tsx.The
useEffect(() => console.error(error), [error])pattern is duplicated verbatim insrc/app/global-error.tsx(Lines 26-28). Extracting a small shared hook removes the duplication and gives a single place to later swap in a real error-reporting service.As per path instructions, "Flag duplicate implementations of the same logic in different files (e.g. two hooks or components solving the same UI concern)."
♻️ Suggested shared hook
+// src/hooks/use-log-error.ts +import { useEffect } from 'react'; + +export function useLogError(error: Error) { + useEffect(() => { + console.error(error); + }, [error]); +}export default function ErrorPage({ error, unstable_retry }: Props) { - useEffect(() => { - console.error(error); - }, [error]); + useLogError(error);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/`[locale]/error.tsx around lines 14 - 16, The error-logging useEffect in this error component is duplicated in global-error.tsx, so extract the shared behavior into a small reusable hook and use it from both components. Move the console.error(error) effect into a named hook (for example, one referenced from error.tsx and global-error.tsx) so there is a single place to later swap in centralized error reporting. Keep the existing behavior unchanged while replacing the duplicated useEffect blocks with the shared hook call.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/app/`[locale]/error.tsx:
- Around line 14-16: The error-logging useEffect in this error component is
duplicated in global-error.tsx, so extract the shared behavior into a small
reusable hook and use it from both components. Move the console.error(error)
effect into a named hook (for example, one referenced from error.tsx and
global-error.tsx) so there is a single place to later swap in centralized error
reporting. Keep the existing behavior unchanged while replacing the duplicated
useEffect blocks with the shared hook call.
In `@src/app/global-error.tsx`:
- Around line 36-40: The fallback copy in global-error.tsx duplicates the
errorPage text used elsewhere, so it can drift if edited separately. Extract the
title, description, and retry label into a shared constant (for example, a small
error-fallback module) and import it here and wherever the English default is
defined, keeping the single source of truth aligned with errorPage and
error.test.tsx.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8a6440ac-4b76-46c5-b20e-1e1d5d84592a
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (18)
package.jsonsrc/app/[locale]/error.test.tsxsrc/app/[locale]/error.tsxsrc/app/[locale]/layout.tsxsrc/app/[locale]/page.tsxsrc/app/global-error.test.tsxsrc/app/global-error.tsxsrc/components/error-card/error-card.tsxsrc/components/header/header.tsxsrc/components/index.tssrc/i18n/messages/en.jsonsrc/i18n/messages/ru.jsonsrc/providers/mui-provider.tsxsrc/providers/toast-provider/Toast.test.tsxsrc/providers/toast-provider/Toast.tsxsrc/providers/toast-provider/ToastProvider.test.tsxsrc/providers/toast-provider/ToastProvider.tsxsrc/providers/toast-provider/types.ts
💤 Files with no reviewable changes (1)
- src/app/[locale]/page.tsx
✅ Files skipped from review due to trivial changes (4)
- src/providers/toast-provider/Toast.test.tsx
- src/i18n/messages/ru.json
- src/components/index.ts
- src/providers/toast-provider/Toast.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- src/app/[locale]/layout.tsx
- src/components/header/header.tsx
* Story/1 sticky header general (#50) * feat: install next+ts+linter+prettier+ husky+redux * feat: configs + perfectionist + lint fix * feat: install scss * refactor: add some folders * feat: install i18n + basic configs * feat: add internatiolisation * feat: language switcher * feat: dependencies update * feat: add sticky header * feat: add mui Button-and-Link-like component * fix: lint * style: add style for header * refactor: remove css from language selector * refactor: add const for flex styles in the header boxes * refactor: history style as link * fix: add some fixes * feat: schema json yaml support (#63) * chore: setup libraries * feat: swagger-editor * refactor: move title and description into a separated component * refactor: moved controls into the swaggerControl component * chore: update package-lock.json * fix: fix import in swagger-view * feat: add translations into SwaggerControl, SwaggerEditor, SwaggerViewer * fix: fix title translation in main text * fix: enforce unique keys when parsing YAML * refactor: extract DEFAULT_SCHEMA into a constant * feat: add tooltip explaining disabled format toggle * test: add test coverage for schema editing flow * fix: resolve component type errors in swagger viewer * fix: add request timeout with AbortController * fix: preserve Monaco editor undo history and cursor position on format switch * fix: prevent restore fetch from overwriting user-edited schema * fix: handle rejected promise in restoreSchema to prevent unhandled rejection * fix: replace missing setEditorValue with handleEditorChange in SwaggerEditor * fix: apply syntax highlighting immediately on editor mount * fix: preserve original JSON parse error * fix: disable external $ref resolution in schema validation to prevent SSRF * refactor: split SwaggerControl into service, component, and helper move save request to schema-service extract FormatToggle component extract getSignalWithTimeout helper switch errors to toast notifications * refactor: rename useSwaggerHook and drop unnecessary useMemo * test: fix tests after refactor * refactor: extract duplicated language-setting logic into helper in SwaggerMonacoEditor * refactor: remove redundant SwaggerViewer title * fix: use translated conversionError message instead of hardcoded string * refactor: extract SchemaFormat and isRecord into shared schema-types module * fix: reserve space for status alert to prevent layout shift on locale switch * feat: sync Monaco editor theme with app color scheme * style: add shadow, border-radius, deduplicate panel styles * test: fix ReactElement import in swagger-control tests * feat: extract schema fetch logic into SchemaService with restore and save methods * fix: extract magic number into named constant * refactor: extract isRecord type guard into its own module * fix: validate restore payload and cancel restore request on unmount * test: add tests for monaco theme * feat: add SwaggerViewer placeholder component * fix: route SwaggerControl toast messages through shared toaster namespace --------- Co-authored-by: Yulia Demir <Nightelfin91@gmail.com> * fix: remove duplicate SwaggerViewer implementation in swagger-view folder * fix: remove unused key from swaggerControl i18n namespace * fix: guard non-object JSON in SchemaService.restore * refactor: catch unhandled rejection in debounced validation --------- Co-authored-by: YuliaDemir <129578495+YuliaDemir@users.noreply.github.com> Co-authored-by: Yulia Demir <Nightelfin91@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (6)
package.json (1)
33-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor MUI version skew across related packages.
@mui/materialis pinned to^9.1.2while@mui/icons-materialand@mui/material-nextjsare pinned to^9.1.1. These packages are typically released in lockstep; aligning them avoids subtle icon/theme mismatches down the line.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` around lines 33 - 35, The MUI package versions are slightly out of sync across the related dependencies, so align the versions in package.json for `@mui/material`, `@mui/icons-material`, and `@mui/material-nextjs` to the same release. Update the dependency entries together so the MUI packages stay in lockstep and can be located easily by their package names in the dependency list.src/components/swagger-control/swagger-control.test.tsx (1)
62-93: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test for the timeout/AbortError branch.
Tests cover the success and generic-failure paths but not the
AbortError→requestTimeoutErrortoast branch inhandleSaveSchema. Consider adding a case that rejects the fetch promise with anAbortError-named error to cover this branch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/swagger-control/swagger-control.test.tsx` around lines 62 - 93, The SwaggerControl tests cover success and generic failure, but they do not exercise the AbortError path in handleSaveSchema. Add a new test alongside the existing save endpoint cases that mocks global.fetch to reject with an error whose name is AbortError, then assert the UI shows the requestTimeoutError toast. Use SwaggerControl, handleSaveSchema behavior, and the existing renderWithToast/userEvent patterns to locate the right test block.src/components/swagger-control/swagger-control.tsx (1)
29-32: 🔒 Security & Privacy | 🔵 Trivial | 🏗️ Heavy liftHardcoded auth bypass behind TODO.
isAuthenticatedis hardcodedtrue, so the Save button and its side effects run for every user regardless of real auth state. This matches the PR's stated incomplete-auth scope, but flagging so it isn't missed before merge.Want help wiring this to the real auth state once it lands?
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/swagger-control/swagger-control.tsx` around lines 29 - 32, The auth state in swagger-control is hardcoded to true, so replace the temporary placeholder with the real authentication source before Save-related behavior depends on it. Update the isAuthenticated logic in SwaggerControl to read from the actual auth state/provider instead of the inline object literal, and keep the existing Save button gating tied to that symbol so unauthorized users cannot trigger the side effects.src/components/swagger-monaco-editor/swagger-monaco-editor.tsx (1)
38-60: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor:
applyLanguageomitted fromuseEffectdependencies.The effect only depends on
format, relying oneditorRef/monacoRefbeing stable refs; functionally correct but may triggerreact-hooks/exhaustive-depslint warnings. Not blocking.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/swagger-monaco-editor/swagger-monaco-editor.tsx` around lines 38 - 60, The `useEffect` that calls `applyLanguage` in `swagger-monaco-editor.tsx` is missing the function from its dependency list, which can trigger `react-hooks/exhaustive-deps` warnings. Update the effect to include `applyLanguage` alongside `format`, and keep the `applyLanguage` helper in sync with the `handleMount` flow so the language update logic remains centralized and lint-compliant.src/components/swagger-viewer/swagger-viewer.tsx (1)
13-13: 🎯 Functional Correctness | 🔵 TrivialTODO: placeholder implementation.
SwaggerVieweris a stub per the TODO comment; real viewer rendering (endpoint list/tree) is not implemented yet.Would you like help scaffolding the real endpoint viewer (list, expand/collapse per path/method), or should this be tracked in a separate issue per the PR's "viewer features" incomplete-items list?
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/swagger-viewer/swagger-viewer.tsx` at line 13, SwaggerViewer is still a placeholder stub and does not render the actual endpoint viewer UI. Replace the TODO implementation in SwaggerViewer with real Swagger rendering logic that displays the API endpoints, including a list/tree of paths and methods and any needed expand/collapse behavior, using the existing SwaggerViewer component as the entry point. If the full viewer is intentionally out of scope for this PR, keep only a minimal non-placeholder implementation and move the remaining viewer features to a separate tracked issue.src/utils/hooks/use-swagger.ts (1)
97-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDrop
setErrorfromuseSwagger’s public return value. No current consumer uses it, so the hook can keep that state private and avoid leaking an internal setter.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/utils/hooks/use-swagger.ts` around lines 97 - 106, Remove the internal error setter from the public API of useSwagger by taking setError out of the object returned from the hook. Keep the error state managed inside useSwagger itself and leave the existing consumers on editorValue, error, format, handleEditorChange, handleFormatToggle, isValid, and schema unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/swagger-control/swagger-control.tsx`:
- Around line 36-58: The async save flow in handleSaveSchema can still call
setIsSaving(false) after unmount, causing a React state-update warning. Add an
unmount guard in swagger-control.tsx around handleSaveSchema, either by tracking
mounted state with a ref or aborting the in-flight SchemaService.save request on
unmount, and only update state in the finally block when the component is still
mounted.
In `@src/services/schema-service.ts`:
- Around line 23-37: The restore() method in schema-service.ts is treating every
non-2xx fetch response as “no saved schema,” which hides real server failures
from callers like use-swagger.ts. Update restore() to distinguish a true
missing-schema case from actual backend errors: only return null for the
intended “not found/no data” response, and for other !response.ok cases throw or
reject with the response error so the caller can surface it. Keep the existing
restore() and save() error-handling behavior aligned, using the restore()
function and its fetch('/api/schema') response handling as the main place to fix
this.
In `@src/utils/hooks/use-swagger.ts`:
- Around line 29-49: The useEffect in use-swagger is vulnerable to stale async
validation results overwriting newer editorValue state. Add a run/version guard
inside the validateSwaggerSchema promise chain so only the latest debounce cycle
can call setIsValid, setError, setSchema, and setFormat. Use the existing
useEffect cleanup plus a local token/flag tied to editorValue to ignore older
resolve/catch callbacks.
- Around line 51-76: The restore flow in useSwagger is only clearing the
timeout, so SchemaService.restore(signal) can continue after unmount. Update
getSignalWithTimeout to expose an abortable cleanup, not just timer clearing,
and make the useEffect cleanup call that abort path. Keep the existing
restoreSchema and restoreError handling, but ensure the AbortController is
actually aborted when the effect tears down.
In `@src/utils/network/get-signal-with-timeout.ts`:
- Around line 1-10: The getSignalWithTimeout API currently exposes only cleanup,
which only clears the timeout and cannot cancel the AbortController request.
Update getSignalWithTimeout to return a separate abort action alongside cleanup
and signal, and use distinct semantics in callers such as use-swagger.ts and
swagger-control.tsx so React unmount cleanup can actually abort the pending
request while request-settlement paths still clear the timer. Ensure the unique
symbols getSignalWithTimeout and cleanup are updated consistently wherever they
are consumed.
---
Nitpick comments:
In `@package.json`:
- Around line 33-35: The MUI package versions are slightly out of sync across
the related dependencies, so align the versions in package.json for
`@mui/material`, `@mui/icons-material`, and `@mui/material-nextjs` to the same
release. Update the dependency entries together so the MUI packages stay in
lockstep and can be located easily by their package names in the dependency
list.
In `@src/components/swagger-control/swagger-control.test.tsx`:
- Around line 62-93: The SwaggerControl tests cover success and generic failure,
but they do not exercise the AbortError path in handleSaveSchema. Add a new test
alongside the existing save endpoint cases that mocks global.fetch to reject
with an error whose name is AbortError, then assert the UI shows the
requestTimeoutError toast. Use SwaggerControl, handleSaveSchema behavior, and
the existing renderWithToast/userEvent patterns to locate the right test block.
In `@src/components/swagger-control/swagger-control.tsx`:
- Around line 29-32: The auth state in swagger-control is hardcoded to true, so
replace the temporary placeholder with the real authentication source before
Save-related behavior depends on it. Update the isAuthenticated logic in
SwaggerControl to read from the actual auth state/provider instead of the inline
object literal, and keep the existing Save button gating tied to that symbol so
unauthorized users cannot trigger the side effects.
In `@src/components/swagger-monaco-editor/swagger-monaco-editor.tsx`:
- Around line 38-60: The `useEffect` that calls `applyLanguage` in
`swagger-monaco-editor.tsx` is missing the function from its dependency list,
which can trigger `react-hooks/exhaustive-deps` warnings. Update the effect to
include `applyLanguage` alongside `format`, and keep the `applyLanguage` helper
in sync with the `handleMount` flow so the language update logic remains
centralized and lint-compliant.
In `@src/components/swagger-viewer/swagger-viewer.tsx`:
- Line 13: SwaggerViewer is still a placeholder stub and does not render the
actual endpoint viewer UI. Replace the TODO implementation in SwaggerViewer with
real Swagger rendering logic that displays the API endpoints, including a
list/tree of paths and methods and any needed expand/collapse behavior, using
the existing SwaggerViewer component as the entry point. If the full viewer is
intentionally out of scope for this PR, keep only a minimal non-placeholder
implementation and move the remaining viewer features to a separate tracked
issue.
In `@src/utils/hooks/use-swagger.ts`:
- Around line 97-106: Remove the internal error setter from the public API of
useSwagger by taking setError out of the object returned from the hook. Keep the
error state managed inside useSwagger itself and leave the existing consumers on
editorValue, error, format, handleEditorChange, handleFormatToggle, isValid, and
schema unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e625216d-27db-4edc-af8f-bcb1a34fee74
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (33)
package.jsonsrc/app/[locale]/page.tsxsrc/app/globals.csssrc/components/format-toggle/format-toggle.tsxsrc/components/header/header.tsxsrc/components/index.tssrc/components/main-text/main-text.test.tsxsrc/components/main-text/main-text.tsxsrc/components/swagger-control/swagger-control.test.tsxsrc/components/swagger-control/swagger-control.tsxsrc/components/swagger-editor/swagger-editor.test.tsxsrc/components/swagger-editor/swagger-editor.tsxsrc/components/swagger-monaco-editor/swagger-monaco-editor.test.tsxsrc/components/swagger-monaco-editor/swagger-monaco-editor.tsxsrc/components/swagger-viewer/swagger-viewer.tsxsrc/constants/default-schema.tssrc/constants/index.tssrc/i18n/messages/en.jsonsrc/i18n/messages/ru.jsonsrc/services/schema-service.tssrc/types/index.tssrc/utils/hooks/use-swagger.test.tssrc/utils/hooks/use-swagger.tssrc/utils/network/get-signal-with-timeout.tssrc/utils/swagger-editor/get-swagger-endpoints.tssrc/utils/swagger-editor/is-record.tssrc/utils/swagger-editor/schema-format-convert.test.tssrc/utils/swagger-editor/schema-format-parse.test.tssrc/utils/swagger-editor/schema-format.tssrc/utils/swagger-editor/schema-types.tssrc/utils/swagger-editor/swagger-validation.test.tssrc/utils/swagger-editor/swagger-validation.tstsconfig.json
💤 Files with no reviewable changes (1)
- src/app/globals.css
✅ Files skipped from review due to trivial changes (2)
- src/utils/swagger-editor/is-record.ts
- src/types/index.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/components/header/header.tsx
- tsconfig.json
- src/i18n/messages/ru.json
- src/i18n/messages/en.json
* chore: supabase setup (#73) * chore: install the @supabase/supabase-js and @supabase/ssr helper packages * feat: add Supabase browser client * feat: add Supabase server client * docs: add .env.example * chore: add .env.local to gitignore * docs: update README with project description, setup instructions, and environment variables * feat: integrate Supabase session refresh into proxy * test: add tests for Supabase browser client, server client, and proxy * chore: ensure .env.example is tracked * fix: log getClaims errors in proxy * test: fix after review * fix: pass response headers through setAll in proxy and add test coverage * feat: proxy route protection (#75) * feat: add page stubs for about, history, sign-in, and sign-up routes * feat: redirect authenticated users away from sign-in/sign-up routes * feat: protect private routes with 401 and redirect expired/invalid sessions * test: add tests for getAuthenticatedUser, Unauthorized page, and proxy auth-route redirects * fix: stricter route matching, error handling, cookie and locale preservation on redirect * fix: wrap getClaims() in try/catch in getAuthenticatedUser * refactor: use ROUTES constants and simplify locale/route matching * fix: forward setAll headers on auth-route redirect * docs: link to Supabase SSR guide in browser and server client files * feat: auth forms integration (#79) * feat: add AuthProvider with signOut and reactive auth state * test: add unit tests for AuthProvider and AuthNavigation component * refactor: update ru sign-up label * chore: install zod, react-hook-form, @hookform/resolvers * feat: add sign-in and sign-up forms with zod validation * feat: connect SignIn and SignUp forms to Supabase auth * fix: redirect to home after sign out to leave protected routes * test: cover auth-schemas, auth-card, controlled-text-field, sign-in and sign-up forms * fix: handle rejected Supabase calls in auth flows * fix: show a redirecting indicator in the unauthorized boundary * fix: remove unnecessary 'use client' directive from AuthCard * fix: add type="button" to password visibility toggle to prevent accidental form submission * fix: rebuild proxy response after mutating cookies * test: update tests and proxy.tsx
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (3)
src/providers/auth-provider/AuthProvider.test.tsx (1)
17-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove unused/broken
authStateChangeCallbackcapture mechanism.This parameter is never passed by any test in this file, and even if it were,
Object.assign(authStateChangeCallback, callback)can't reassign the caller's reference to a function — it only copies enumerable properties. The later tests correctly capture the callback via a closure (lines 74-85) instead. Recommend dropping the dead/non-functional path to avoid a future footgun.♻️ Proposed cleanup
function mockSupabaseClient({ - authStateChangeCallback, user, }: { - authStateChangeCallback?: (event: string, session: unknown) => void; user: unknown; }) { const unsubscribe = vi.fn(); const signOut = vi.fn().mockResolvedValue({ error: null }); return { auth: { getUser: vi.fn().mockResolvedValue({ data: { user } }), - onAuthStateChange: vi.fn((callback: (event: string, session: unknown) => void) => { - if (authStateChangeCallback) { - Object.assign(authStateChangeCallback, callback); - } - return { data: { subscription: { unsubscribe } } }; - }), + onAuthStateChange: vi.fn(() => ({ data: { subscription: { unsubscribe } } })), signOut, }, } as unknown as ReturnType<typeof createClient>; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/auth-provider/AuthProvider.test.tsx` around lines 17 - 39, Remove the unused authStateChangeCallback parameter from mockSupabaseClient and delete the conditional Object.assign capture logic inside onAuthStateChange. Keep callback registration behavior intact so tests can continue capturing callbacks through their existing closures.src/components/controlled-text-field/controlled-text-field.tsx (1)
35-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLocalize the password-toggle
aria-label.
t(labelKey)and error text are translated, but"toggle password visibility"is hardcoded English. Screen-reader users on therulocale would hear an English string.🌐 Suggested fix
<IconButton - aria-label="toggle password visibility" + aria-label={t('togglePasswordVisibility')} edge="end"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/controlled-text-field/controlled-text-field.tsx` around lines 35 - 48, Localize the hardcoded aria-label in the passwordToggleButton by passing an appropriate translation key through the existing t translation function. Preserve the toggle behavior and ensure the label reflects the current password visibility state where supported by the existing translations.src/components/sign-in-form/sign-in-form.tsx (1)
62-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate form-shell markup with
sign-up-form.tsx.The
Boxwrapper (sxstyling,autoComplete="off",noValidate) and submitButtonare copy-pasted between this file andsign-up-form.tsx(Lines 68-119 there). Consider extracting a shared<AuthFormShell>(or similar) that accepts children + submit label, to keep the two forms' shells in sync.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/sign-in-form/sign-in-form.tsx` around lines 62 - 105, The sign-in and sign-up forms duplicate their shared form shell markup. Extract the common Box wrapper and submit Button into an AuthFormShell component that accepts children and the submit label, then update the sign-in form and sign-up form to use it while preserving their existing fields, submission handlers, styling, and disabled-state behavior.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 9-11: Update the README feature list to match the PR’s implemented
scope: mark the interactive Swagger viewer, schema persistence through
registration/sign-in, and authenticated request history/analytics as planned or
incomplete, unless those capabilities are now implemented. Do not present these
items as currently available.
In `@src/app/`[locale]/about/page.tsx:
- Around line 1-2: Replace the placeholder JSX returned by AboutPage with the
localized About-page content, including RS School information, team details,
GitHub links, and the supported multi-language presentation. Reuse the project’s
existing localization and shared UI components or content patterns rather than
hardcoding a single-language placeholder.
In `@src/proxy.ts`:
- Around line 16-41: Update the Supabase client’s cookies.setAll handler to
preserve the response produced by handleIntl(request) instead of replacing it
with NextResponse.next({ request }); mutate the existing response while applying
refreshed cookies and headers. Add a regression test covering the next-intl
default-locale redirect path, ensuring the redirect remains intact when Supabase
refreshes cookies.
In `@src/utils/auth/auth-schemas.ts`:
- Around line 16-18: Update the password schema’s digit validation regex
alongside the existing letter and special-character checks to use the Unicode
decimal-digit property, so non-ASCII digits satisfy the digit requirement and
are excluded from special-character classification. Preserve the existing
password length, letter, and special-character rules.
In `@src/utils/auth/get-authenticated-user.ts`:
- Around line 5-20: Move the data/error validation out of the try block in
getAuthenticatedUser, retaining only the getClaims call and unexpected-error
logging in the catch. After the catch, invoke unauthorized() once when data is
absent or an authentication error exists, and update
get-authenticated-user.test.ts to verify the interrupt occurs only once.
---
Nitpick comments:
In `@src/components/controlled-text-field/controlled-text-field.tsx`:
- Around line 35-48: Localize the hardcoded aria-label in the
passwordToggleButton by passing an appropriate translation key through the
existing t translation function. Preserve the toggle behavior and ensure the
label reflects the current password visibility state where supported by the
existing translations.
In `@src/components/sign-in-form/sign-in-form.tsx`:
- Around line 62-105: The sign-in and sign-up forms duplicate their shared form
shell markup. Extract the common Box wrapper and submit Button into an
AuthFormShell component that accepts children and the submit label, then update
the sign-in form and sign-up form to use it while preserving their existing
fields, submission handlers, styling, and disabled-state behavior.
In `@src/providers/auth-provider/AuthProvider.test.tsx`:
- Around line 17-39: Remove the unused authStateChangeCallback parameter from
mockSupabaseClient and delete the conditional Object.assign capture logic inside
onAuthStateChange. Keep callback registration behavior intact so tests can
continue capturing callbacks through their existing closures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8ab11cd6-03f2-4a22-a244-36c547f963a5
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (39)
.env.example.gitignoreREADME.mdnext.config.tspackage.jsonsrc/app/[locale]/about/page.tsxsrc/app/[locale]/history/page.tsxsrc/app/[locale]/layout.tsxsrc/app/[locale]/sign-in/page.tsxsrc/app/[locale]/sign-up/page.tsxsrc/app/[locale]/unauthorized.test.tsxsrc/app/[locale]/unauthorized.tsxsrc/components/auth-card/auth-card.test.tsxsrc/components/auth-card/auth-card.tsxsrc/components/auth-navigation/auth-navigation.test.tsxsrc/components/auth-navigation/auth-navigation.tsxsrc/components/controlled-text-field/controlled-text-field.test.tsxsrc/components/controlled-text-field/controlled-text-field.tsxsrc/components/sign-in-form/sign-in-form.test.tsxsrc/components/sign-in-form/sign-in-form.tsxsrc/components/sign-up-form/sign-up-form.test.tsxsrc/components/sign-up-form/sign-up-form.tsxsrc/components/swagger-control/swagger-control.test.tsxsrc/components/swagger-control/swagger-control.tsxsrc/components/swagger-editor/swagger-editor.test.tsxsrc/i18n/messages/en.jsonsrc/i18n/messages/ru.jsonsrc/lib/client.test.tssrc/lib/client.tssrc/lib/server.test.tssrc/lib/server.tssrc/providers/auth-provider/AuthProvider.test.tsxsrc/providers/auth-provider/AuthProvider.tsxsrc/proxy.test.tssrc/proxy.tssrc/utils/auth/auth-schemas.test.tssrc/utils/auth/auth-schemas.tssrc/utils/auth/get-authenticated-user.test.tssrc/utils/auth/get-authenticated-user.ts
🚧 Files skipped from review as they are similar to previous changes (9)
- src/components/swagger-editor/swagger-editor.test.tsx
- next.config.ts
- src/app/[locale]/layout.tsx
- src/i18n/messages/ru.json
- src/components/swagger-control/swagger-control.test.tsx
- package.json
- .gitignore
- src/i18n/messages/en.json
- src/components/swagger-control/swagger-control.tsx
* feat: add tests for header and language switcher * fix: sign-in sign-up tests by mocking unnecessary components * feat: add test for layout amd mui provider * fix: tests
* feat: render swagger endpoint list * feat: render endpoint details * feat: add try-it-out execution * fix: harden try-it-out request execution * fix: pin try-it-out requests to validated IPs * fix: handle try-it-out response stream errors * feat: add curl generation * fix: keep generated curl command current * refactor: split swagger viewer components * refactor: split try-it-out panel sections * fix: harden try-it-out panel behavior * feat: persist try-it-out history * fix: cap try-it-out response size * fix: harden try-it-out proxy --------- Co-authored-by: Ivan-khodorov <187195904+Ivan-khodorov@users.noreply.github.com>
* feat: add History page with empty state and paginated table view * test: cover History page, history list, history empty state, and getRequestHistory * feat: add server-side request history persistence * test: add tests for saveRequestHistory * fix: handle unexpected errors when loading request history * fix: prevent rendering history list on load failure * fix: improve handle request history save failures * refactor: simplify history page conditional rendering * refactor: improve pagination code readability * refactor: simplify history table header rendering
* feat: persist swagger schemas * fix: validate persisted schemas --------- Co-authored-by: Ivan-khodorov <187195904+Ivan-khodorov@users.noreply.github.com>
Co-authored-by: Ivan-khodorov <187195904+Ivan-khodorov@users.noreply.github.com>
* fix: header test * fix: remove unnecessary test * fix: add test timeout
* fix: header test * fix: remove unnecessary test * fix: add test timeout * test: fix tests * refactor: update tests --------- Co-authored-by: Yulia Demir <Nightelfin91@gmail.com>
* refactor: add import instead of using inner constant * style: style MuiOutlinedInput and MuiPaper * chore: uninstall reduxjs/toolkit react-redux
2. Screenshots
Feature 1: App Header
Feature 2: Sign In / Sign Up
Feature 3: Swagger Editor
Feature 4: Swagger Viewer
Feature 5: History and Analytics
Feature 6: About Page
Feature 7: General Requirements
Feature 8: YouTube Video