Skip to content

Dev tazi 001#1

Merged
swoosh1337 merged 2 commits intomainfrom
dev-tazi-001
Aug 10, 2025
Merged

Dev tazi 001#1
swoosh1337 merged 2 commits intomainfrom
dev-tazi-001

Conversation

@swoosh1337
Copy link
Collaborator

@swoosh1337 swoosh1337 commented Aug 9, 2025

Summary by CodeRabbit

  • New Features

    • Added a comprehensive CI/CD documentation file with workflow details, local development instructions, troubleshooting, and future plans.
    • Introduced a structured repository of Python solutions for common algorithmic problems, including code, complexity, and explanations.
    • Added a React hook to manage user submissions for problems, supporting fetch, error handling, and refetch.
    • Enhanced the problem-solving interface with syntax-highlighted code solutions, improved submissions display, and scrollable panels.
    • Added scripts and npm commands to streamline development and API startup.
  • Bug Fixes

    • Improved LaTeX math rendering and markdown styling in AI chat messages.
    • Enhanced debounced save logic in notes to ensure pending changes are saved on cleanup.
  • Refactor

    • Updated type declarations for UI component props for consistency.
    • Improved value rendering and formatting for test results and submissions.
    • Updated code snippet and import suggestion logic in the AI assistant to better respect user intent and reduce unsolicited code.
  • Chores

    • Added and customized ESLint rules and overrides for better linting across different file types.
    • Added a Bash script to automate frontend and API server startup with health checks and environment setup.
  • Tests

    • Removed legacy and integration test scripts no longer required for the current workflow.
  • Documentation

    • Added detailed CI/CD and local development documentation.
  • Style

    • Improved UI consistency and readability for markdown, code blocks, and scrollable panels.

@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

Walkthrough

This update introduces new internal tools, scripts, and data structures, refines UI components, and removes legacy test scripts. Notable additions include a Python solutions data module, a submissions management hook, improved solution and submissions rendering in the problem solver, and a unified development startup script. Several test and integration scripts are deleted, and ESLint configuration is enhanced for contextual code linting.

Changes

Cohort / File(s) Change Summary
ESLint Configuration
.eslintrc.overrides.js, eslint.config.js, tailwind.config.ts
Introduces contextual ESLint overrides for specific file groups, adds new TypeScript lint rules as warnings, and disables a require-imports rule for Tailwind plugins.
CI/CD and Development Scripts
CI_CD_README.md, scripts/dev-start.sh, package.json
Adds comprehensive CI/CD documentation, a unified Bash script for starting frontend and API servers, and new npm scripts for development and CI.
Test and Integration Script Removal
test-connection.js, test-dynamic-problems.js, test-judge0.js, test-leetcode-style.js, test-supabase-integration.js
Deletes all legacy test and integration scripts related to API, Judge0, LeetCode-style, and Supabase testing.
Python Solutions Data
src/data/pythonSolutions.ts
Adds a new module exporting structured Python solutions for several algorithm problems, including code, complexity, and explanations.
Submissions Management
src/hooks/useSubmissions.ts, src/services/userAttempts.ts
Adds a React hook and a service method for fetching and managing user submissions, with new fields for test results and metadata.
Problem Solver Enhancements
src/pages/ProblemSolver.tsx
Refactors the ProblemSolver UI: adds scrollable panels, syntax-highlighted code, dynamic solution and submission rendering, deduplication, and improved JSON formatting.
AI Chat and Notes Improvements
src/components/AIChat.tsx, src/components/Notes.tsx
Adds LaTeX math notation cleaning to AI assistant messages, improves markdown rendering, and ensures debounced saves are flushed on cleanup in Notes.
UI Component Type Refactoring
src/components/ui/command.tsx, src/components/ui/textarea.tsx
Changes props type declarations from interfaces to type aliases for CommandDialogProps and TextareaProps.
Hooks and Internal Logic Tweaks
src/hooks/useChatSession.ts, src/hooks/useProblems.ts, code-executor-api/server.js, supabase/functions/ai-chat/index.ts
Refines snippet deduplication and filtering in chat, updates Supabase query variable to const, adjusts code execution logic, and tightens AI tutor prompt and snippet gating.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProblemSolver
    participant useSubmissions
    participant UserAttemptsService
    participant pythonSolutions

    User->>ProblemSolver: Open problem page
    ProblemSolver->>useSubmissions: Fetch submissions (userId, problemId)
    useSubmissions->>UserAttemptsService: getAcceptedSubmissions(userId, problemId)
    UserAttemptsService-->>useSubmissions: Array of submissions
    useSubmissions-->>ProblemSolver: { submissions, loading, error }
    ProblemSolver->>pythonSolutions: Load solutions for problemId
    pythonSolutions-->>ProblemSolver: Array of Solution objects
    ProblemSolver->>User: Render problem, solutions, submissions, notes
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

🐇✨
A hop through code, a leap through time,
Old tests retired, new scripts in line.
Python wisdom now on show,
Submissions tracked as users grow.
Scroll and copy, highlight bright—
The solver’s panels feel just right.
With linting tuned and docs anew,
This bunny’s proud of all we do!

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bedd4c1 and a1abe62.

📒 Files selected for processing (1)
  • src/pages/ProblemSolver.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/ProblemSolver.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev-tazi-001

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gitguardian

This comment was marked as resolved.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🔭 Outside diff range comments (1)
src/pages/ProblemSolver.tsx (1)

120-151: Stabilise keyboard-shortcut listener

toggleLeft/Bottom/RightPanel are recreated on every render, so the effect’s dependency array changes each time, causing the global keydown listener to be detached/attached on each render.
Wrap the three toggles in useCallback (or move them outside component scope) and give the effect an empty dependency list to register the listener once.

-const toggleLeftPanel = () => { … }
+const toggleLeftPanel = useCallback(() => { … }, [showLeftPanel]);
🧹 Nitpick comments (5)
.github/workflows/ci.yml (2)

1-9: Add least-privilege permissions and cancel in-progress runs

Reduce GITHUB_TOKEN scope and cancel superseded runs to save CI minutes.

 name: CI/CD Pipeline
 
 on:
   push:
     branches: [ main ]
   pull_request:
     branches: [ main ]
 
+permissions:
+  contents: read
+
+concurrency:
+  group: ci-${{ github.ref }}-${{ github.workflow }}
+  cancel-in-progress: true

172-179: Optional: add job timeouts to avoid hanging runners

Set timeout-minutes per job to prevent stuck processes from burning CI minutes.

Example:

   deploy-staging:
     name: Deploy to Staging
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-latest
+    timeout-minutes: 15

Consider similar timeouts for the other jobs (e.g., 20–30 minutes).

Also applies to: 175-176

src/pages/ProblemSolver.tsx (3)

39-47: Remove leftover debug effect

This useEffect only queries DOM nodes and stores them in an unused variable – it produces no side-effects and will keep running on every tab switch.
Drop it or convert it to a real implementation to avoid dead code.


81-106: Quoted string output may look odd

toCompactJson returns JSON.stringify(value) for plain strings, so "abc" becomes "\"abc\"".
If the goal is to show raw strings (like test outputs) without double quoting, strip the outer quotes when typeof value === 'string' && !looksLikeJson.


412-470: Unused helper – consider removing

toHumanReadable isn’t referenced anywhere in the component. Dead code increases bundle size and maintenance cost; delete it unless you plan to use it imminently.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4256892 and 62478c2.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • src/components/AIChat.tsx (3 hunks)
  • src/pages/ProblemSolver.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/AIChat.tsx
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

24-24: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[error] 13-13: trailing spaces

(trailing-spaces)


[error] 56-56: trailing spaces

(trailing-spaces)


[error] 87-87: trailing spaces

(trailing-spaces)


[error] 90-90: trailing spaces

(trailing-spaces)


[error] 93-93: trailing spaces

(trailing-spaces)


[error] 101-101: trailing spaces

(trailing-spaces)


[error] 139-139: trailing spaces

(trailing-spaces)


[error] 143-143: trailing spaces

(trailing-spaces)


[error] 146-146: trailing spaces

(trailing-spaces)


[error] 150-150: trailing spaces

(trailing-spaces)


[error] 153-153: trailing spaces

(trailing-spaces)


[error] 162-162: trailing spaces

(trailing-spaces)


[error] 190-190: trailing spaces

(trailing-spaces)


[error] 210-210: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
src/pages/ProblemSolver.tsx (1)

11-13: Verify new dependency inclusion

safe-stable-stringify is imported but there’s no guarantee it’s listed in package.json. Ensure the dependency is added so builds don’t fail.

@swoosh1337 swoosh1337 force-pushed the dev-tazi-001 branch 2 times, most recently from 8b49ef5 to 1c5e64a Compare August 10, 2025 14:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (10)
.github/workflows/dev-test.yml (2)

47-54: Combine redirects when writing .env (SC2129)

Use a grouped redirect or here-doc for clarity and shellcheck compliance.

     - name: Create test environment for API
       working-directory: ./code-executor-api
       run: |
-        echo "PORT=3001" > .env
-        echo "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com" >> .env
-        echo "SUPABASE_URL=test-url" >> .env
-        echo "SUPABASE_SERVICE_ROLE_KEY=test-key" >> .env
+        {
+          printf "PORT=3001\n"
+          printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n"
+          printf "SUPABASE_URL=test-url\n"
+          printf "SUPABASE_SERVICE_ROLE_KEY=test-key\n"
+        } > .env

13-13: Fix YAML lint issues: trailing spaces and final newline

Remove trailing spaces on these lines and add a newline at end of file to satisfy yamllint.

Also applies to: 63-63, 66-66, 70-70, 73-73, 76-76, 79-79, 81-81, 90-90, 97-97

CI_CD_README.md (1)

8-8: Use proper headings instead of bold (MD036)

Convert emphasis used as headings to actual Markdown headings for lint compliance.

-**Comprehensive testing and deployment pipeline**
+#### Comprehensive testing and deployment pipeline
@@
-**Quick testing for development branches**
+#### Quick testing for development branches

Also applies to: 42-42

.github/workflows/ci.yml (7)

56-61: Silence SC2034 and improve readiness check

Avoid unused loop variable by using timeout+until; keeps intent and removes shellcheck warning.

-        for i in {1..60}; do
-          if curl -fsS http://localhost:4173/ > /dev/null; then
-            break
-          fi
-          sleep 1
-        done
+        timeout 60s bash -lc 'until curl -fsS http://localhost:4173/ >/dev/null; do sleep 1; done'

95-101: Combine .env writes to avoid SC2129 and improve clarity

Group redirects so we don't append multiple times and stay lint-clean.

-        printf "PORT=3001\n" > .env
-        printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n" >> .env
-        printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}" >> .env
-        printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}" >> .env
+        {
+          printf "PORT=3001\n"
+          printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n"
+          printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}"
+          printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}"
+        } > .env

113-118: Replace for-loop with timeout+until (SC2034)

Removes unused loop variable and improves readability.

-        for i in {1..60}; do
-          if curl -fsS http://localhost:3001/health > /dev/null; then
-            break
-          fi
-          sleep 1
-        done
+        timeout 60s bash -lc 'until curl -fsS http://localhost:3001/health >/dev/null; do sleep 1; done'

160-167: Combine .env writes in integration job (SC2129)

Group printf calls under a single redirection.

-        printf "PORT=3001\n" > .env
-        printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n" >> .env
-        printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}" >> .env
-        printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}" >> .env
+        {
+          printf "PORT=3001\n"
+          printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n"
+          printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}"
+          printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}"
+        } > .env

190-196: Use timeout+until to wait for API (SC2034)

Eliminates unused counter variable and keeps behavior.

-        for i in {1..60}; do
-          if curl -fsS http://localhost:3001/health > /dev/null; then
-            break
-          fi
-          sleep 1
-        done
+        timeout 60s bash -lc 'until curl -fsS http://localhost:3001/health >/dev/null; do sleep 1; done'

199-205: Use timeout+until to wait for frontend (SC2034)

Same rationale as above.

-        for i in {1..60}; do
-          if curl -fsS http://localhost:4173/ > /dev/null; then
-            break
-          fi
-          sleep 1
-        done
+        timeout 60s bash -lc 'until curl -fsS http://localhost:4173/ >/dev/null; do sleep 1; done'

85-85: Standardize Node to 20.x across jobs

Use 20.x to get latest patches on LTS and ensure consistency.

-        node-version: '20'
+        node-version: '20.x'

Also applies to: 150-150, 260-260

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62478c2 and 1c5e64a.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (25)
  • .eslintrc.overrides.js (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/dev-test.yml (1 hunks)
  • CI_CD_README.md (1 hunks)
  • code-executor-api/server.js (3 hunks)
  • eslint.config.js (1 hunks)
  • package.json (2 hunks)
  • scripts/dev-start.sh (1 hunks)
  • src/components/AIChat.tsx (3 hunks)
  • src/components/Notes.tsx (1 hunks)
  • src/components/ui/command.tsx (1 hunks)
  • src/components/ui/textarea.tsx (1 hunks)
  • src/data/pythonSolutions.ts (1 hunks)
  • src/hooks/useChatSession.ts (2 hunks)
  • src/hooks/useProblems.ts (1 hunks)
  • src/hooks/useSubmissions.ts (1 hunks)
  • src/pages/ProblemSolver.tsx (9 hunks)
  • src/services/userAttempts.ts (2 hunks)
  • supabase/functions/ai-chat/index.ts (4 hunks)
  • tailwind.config.ts (1 hunks)
  • test-connection.js (0 hunks)
  • test-dynamic-problems.js (0 hunks)
  • test-judge0.js (0 hunks)
  • test-leetcode-style.js (0 hunks)
  • test-supabase-integration.js (0 hunks)
💤 Files with no reviewable changes (5)
  • test-leetcode-style.js
  • test-judge0.js
  • test-dynamic-problems.js
  • test-connection.js
  • test-supabase-integration.js
✅ Files skipped from review due to trivial changes (2)
  • src/hooks/useProblems.ts
  • package.json
🚧 Files skipped from review as they are similar to previous changes (15)
  • tailwind.config.ts
  • src/components/ui/textarea.tsx
  • .eslintrc.overrides.js
  • src/services/userAttempts.ts
  • eslint.config.js
  • src/components/Notes.tsx
  • src/components/ui/command.tsx
  • scripts/dev-start.sh
  • src/hooks/useChatSession.ts
  • src/hooks/useSubmissions.ts
  • code-executor-api/server.js
  • src/components/AIChat.tsx
  • src/data/pythonSolutions.ts
  • supabase/functions/ai-chat/index.ts
  • src/pages/ProblemSolver.tsx
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/ci.yml

44-44: shellcheck reported issue in this script: SC2034:warning:12:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


95-95: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


104-104: shellcheck reported issue in this script: SC2034:warning:9:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


161-161: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


172-172: shellcheck reported issue in this script: SC2034:warning:27:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


263-263: shellcheck reported issue in this script: SC2015:info:1:26: Note that A && B || C is not if-then-else. C may run when A is true

(shellcheck)

.github/workflows/dev-test.yml

29-29: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


49-49: shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

🪛 YAMLlint (1.37.1)
.github/workflows/dev-test.yml

[error] 13-13: trailing spaces

(trailing-spaces)


[error] 63-63: trailing spaces

(trailing-spaces)


[error] 66-66: trailing spaces

(trailing-spaces)


[error] 70-70: trailing spaces

(trailing-spaces)


[error] 73-73: trailing spaces

(trailing-spaces)


[error] 76-76: trailing spaces

(trailing-spaces)


[error] 79-79: trailing spaces

(trailing-spaces)


[error] 81-81: trailing spaces

(trailing-spaces)


[error] 90-90: trailing spaces

(trailing-spaces)


[error] 97-97: no new line character at the end of file

(new-line-at-end-of-file)

🪛 markdownlint-cli2 (0.17.2)
CI_CD_README.md

8-8: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


42-42: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (1)
src/pages/ProblemSolver.tsx (1)

75-81: Keyboard handler re-registers on every render; memoize toggles and stabilize effect

toggleLeft/Bottom/RightPanel are recreated each render, so the keydown effect re-attaches every render. Memoize toggles with useCallback using functional updates and make the effect run once.

-  const toggleLeftPanel = () => {
-    const newValue = !showLeftPanel;
-    setShowLeftPanel(newValue);
-    localStorage.setItem('showLeftPanel', JSON.stringify(newValue));
-  };
+  const toggleLeftPanel = useCallback(() => {
+    setShowLeftPanel(prev => {
+      const newValue = !prev;
+      localStorage.setItem('showLeftPanel', JSON.stringify(newValue));
+      return newValue;
+    });
+  }, []);

-  const toggleBottomPanel = () => {
-    const newValue = !showBottomPanel;
-    setShowBottomPanel(newValue);
-    localStorage.setItem('showBottomPanel', JSON.stringify(newValue));
-  };
+  const toggleBottomPanel = useCallback(() => {
+    setShowBottomPanel(prev => {
+      const newValue = !prev;
+      localStorage.setItem('showBottomPanel', JSON.stringify(newValue));
+      return newValue;
+    });
+  }, []);

-  const toggleRightPanel = () => {
-    const newValue = !showRightPanel;
-    setShowRightPanel(newValue);
-    localStorage.setItem('showRightPanel', JSON.stringify(newValue));
-  };
+  const toggleRightPanel = useCallback(() => {
+    setShowRightPanel(prev => {
+      const newValue = !prev;
+      localStorage.setItem('showRightPanel', JSON.stringify(newValue));
+      return newValue;
+    });
+  }, []);

-  }, [toggleLeftPanel, toggleBottomPanel, toggleRightPanel]);
+  }, []); // toggles are stable due to useCallback

Also add missing imports:

-import { useState, useEffect, useRef } from 'react';
+import { useState, useEffect, useRef, useCallback, useMemo } from 'react';

Also applies to: 108-119, 120-151

♻️ Duplicate comments (3)
.github/workflows/dev-test.yml (2)

23-27: Use Node 20.x and enable npm cache for API install

Align to active LTS and cache npm installs for speed and determinism.

     - name: Setup Node.js for API
       uses: actions/setup-node@v4
       with:
-        node-version: '20'
+        node-version: '20.x'
+        cache: 'npm'
+        cache-dependency-path: 'code-executor-api/package-lock.json'

37-40: Prefer reproducible installs with npm ci

npm ci is faster and respects the lockfile.

     - name: Install API dependencies
       working-directory: ./code-executor-api
-      run: npm install
+      run: npm ci
.github/workflows/ci.yml (1)

262-264: Don’t mask install failures (SC2015) in audit step

Separate install from audit; only ignore audit exit code.

-    - name: Audit frontend dependencies
-      run: bun install --production && bun audit || true
+    - name: Audit frontend dependencies
+      run: |
+        set -euo pipefail
+        bun install --production
+        bun audit || true
🧹 Nitpick comments (14)
.github/workflows/dev-test.yml (2)

47-54: Consolidate .env writes to satisfy shellcheck SC2129 and improve readability

Use a heredoc to avoid multiple redirections.

     - name: Create test environment for API
       working-directory: ./code-executor-api
       run: |
-        echo "PORT=3001" > .env
-        echo "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com" >> .env
-        echo "SUPABASE_URL=https://example.supabase.co" >> .env
-        echo "SUPABASE_SERVICE_ROLE_KEY=dummy-service-role-key" >> .env
+        cat > .env <<'EOF'
+        PORT=3001
+        JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com
+        SUPABASE_URL=https://example.supabase.co
+        SUPABASE_SERVICE_ROLE_KEY=dummy-service-role-key
+        EOF

13-13: YAML lint fixes: trailing spaces and EOF newline

Remove trailing spaces (Line 13, Line 105) and add a newline at EOF (Line 112) to satisfy yamllint.

Also applies to: 105-105, 112-112

CI_CD_README.md (3)

8-8: Use proper headings instead of bold text (MD036)

Convert emphasized lines to headings for markdownlint compliance.

-**Comprehensive testing and deployment pipeline**
+#### Comprehensive testing and deployment pipeline
@@
-**Quick testing for development branches**
+#### Quick testing for development branches

Also applies to: 42-42


21-26: Doc inconsistency: Node.js version is 20 in workflows, not 18

Update the doc to match the workflows.

-2. **test-api** - Tests the Node.js API server
-   - Uses Node.js 18
+2. **test-api** - Tests the Node.js API server
+   - Uses Node.js 20

126-131: Replace placeholder badge URLs before merging

Use the actual org/repo to avoid broken badges.

.github/workflows/ci.yml (4)

93-101: Consolidate .env writes (SC2129) with heredoc

Shellcheck flags multiple >> redirects; use a heredoc.

     - name: Create API environment file
       working-directory: ./code-executor-api
       run: |
-        set -euo pipefail
-        printf "PORT=3001\n" > .env
-        printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n" >> .env
-        printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}" >> .env
-        printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}" >> .env
+        set -euo pipefail
+        cat > .env <<EOF
+        PORT=3001
+        JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com
+        SUPABASE_URL=${SUPABASE_URL:-https://example.supabase.co}
+        SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}
+        EOF

159-167: Deduplicate .env creation approach (SC2129) in integration job

Mirror the heredoc pattern for consistency.

     - name: Create API environment file
       working-directory: ./code-executor-api
       run: |
-        set -euo pipefail
-        printf "PORT=3001\n" > .env
-        printf "JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com\n" >> .env
-        printf "SUPABASE_URL=%s\n" "${SUPABASE_URL:-https://example.supabase.co}" >> .env
-        printf "SUPABASE_SERVICE_ROLE_KEY=%s\n" "${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}" >> .env
+        set -euo pipefail
+        cat > .env <<EOF
+        PORT=3001
+        JUDGE0_API_URL=https://judge0-extra-ce.p.rapidapi.com
+        SUPABASE_URL=${SUPABASE_URL:-https://example.supabase.co}
+        SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY:-dummy-service-role-key}
+        EOF

85-86: Prefer node-version: '20.x' to track latest patch

Minor: use 20.x for consistency with semver patterns in setup-node.

-        node-version: '20'
+        node-version: '20.x'

Also applies to: 150-151, 260-261


43-69: Optional: replace for-loops with timeout+until to avoid SC2034 (“i appears unused”)

Current loops are fine; switch to timeout+until for cleaner lint.

Example:

-        for i in {1..60}; do
-          if curl -fsS http://localhost:4173/ > /dev/null; then
-            break
-          fi
-          sleep 1
-        done
+        timeout 60s bash -lc 'until curl -fsS http://localhost:4173/ >/dev/null; do sleep 1; done'

Also applies to: 112-121, 189-206

src/pages/ProblemSolver.tsx (5)

591-601: Clipboard: add error handling and await the writeText promise

navigator.clipboard.writeText returns a Promise and can fail (permissions, insecure context). Handle rejection and show a toast accordingly.

-                                      <Button 
+                                      <Button 
                                         variant="outline" 
                                         size="sm"
-                                        onClick={() => {
-                                          navigator.clipboard.writeText(solution.code);
-                                          toast.success('Code copied to clipboard!');
-                                        }}
+                                        onClick={async () => {
+                                          try {
+                                            await navigator.clipboard.writeText(solution.code);
+                                            toast.success('Code copied to clipboard!');
+                                          } catch {
+                                            toast.error('Failed to copy to clipboard');
+                                          }
+                                        }}
                                       >
-                                    <Button 
+                                    <Button 
                                       variant="ghost" 
                                       size="sm"
-                                      onClick={() => {
-                                        navigator.clipboard.writeText(submission.code);
-                                        toast.success('Code copied to clipboard!');
-                                      }}
+                                      onClick={async () => {
+                                        try {
+                                          await navigator.clipboard.writeText(submission.code);
+                                          toast.success('Code copied to clipboard!');
+                                        } catch {
+                                          toast.error('Failed to copy to clipboard');
+                                        }
+                                      }}
                                     >

Also applies to: 695-705


862-865: Consistent formatting: pretty-print test input with toCompactJson

Render input using the same compact JSON helper for consistency across expected/actual/input.

-                                    <pre className="text-sm font-mono text-gray-900 dark:text-gray-100 whitespace-pre overflow-x-auto">
-{result.input}
-                                    </pre>
+                                    <pre className="text-sm font-mono text-gray-900 dark:text-gray-100 whitespace-pre overflow-x-auto">
+{toCompactJson(result.input)}
+                                    </pre>

374-410: Remove unused function renderValue

This helper is no longer referenced (replaced by toCompactJson). Keeping it around risks drift and triggers unused warnings in strict setups.

-  const renderValue = (value: any): string => {
-    if (value === null || value === undefined) return 'null';
-    if (typeof value === 'number' || typeof value === 'boolean') return String(value);
-    
-    // Handle arrays and objects directly for pretty printing
-    if (Array.isArray(value)) {
-      try {
-        return JSON.stringify(value, null, 2);
-      } catch {
-        return String(value);
-      }
-    }
-    
-    if (typeof value === 'object') {
-      try {
-        return JSON.stringify(value, null, 2);
-      } catch {
-        return String(value);
-      }
-    }
-    
-    if (typeof value === 'string') {
-      // Try to pretty-print if it's JSON-like
-      const trimmed = value.trim();
-      if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))){
-        try { 
-          const parsed = JSON.parse(trimmed);
-          return JSON.stringify(parsed, null, 2); 
-        } catch { 
-          return value; 
-        }
-      }
-      return value;
-    }
-    
-    return String(value);
-  };

412-471: Remove unused function toHumanReadable (or document intended usage)

Currently unused and sizable; remove to reduce surface area or add a clear TODO with a consumer soon.

-  // Human-friendly formatter (not strict JSON):
-  // - Strings are shown without quotes
-  // - Arrays render as [ a, b ] or multi-line for nested arrays
-  // - Objects render as { key: value }
-  const toHumanReadable = (value: any, indent = 0): string => {
-    const pad = (n: number) => ' '.repeat(n);
-    // If value is a JSON-like string, parse then format recursively
-    if (typeof value === 'string') {
-      const trimmed = value.trim();
-      const looksJson =
-        (trimmed.startsWith('{') && trimmed.endsWith('}')) ||
-        (trimmed.startsWith('[') && trimmed.endsWith(']')) ||
-        (trimmed.startsWith('"') && trimmed.endsWith('"')) ||
-        (trimmed === 'null' || trimmed === 'true' || trimmed === 'false');
-      if (looksJson) {
-        try {
-          const parsed = JSON.parse(trimmed);
-          return toHumanReadable(parsed, indent);
-        } catch {
-          // fall through to scalar formatting
-        }
-      }
-    }
-    const needsQuotes = (s: string): boolean => {
-      return s === '' || /[\s,[\]{}:]/.test(s);
-    };
-    const formatScalar = (v: any): string => {
-      if (v === null || v === undefined) return 'null';
-      const t = typeof v;
-      if (t === 'number' || t === 'boolean') return String(v);
-      if (t === 'string') return needsQuotes(v) ? `"${v}"` : v;
-      return String(v);
-    };
-    if (Array.isArray(value)) {
-      if (value.length === 0) return '[]';
-      const complex = value.some((el) => Array.isArray(el) || (el && typeof el === 'object'));
-      if (complex) {
-        const inner = value
-          .map((el) => `${pad(indent + 2)}${toHumanReadable(el, indent + 2)}`)
-          .join(',\n');
-        return `[\n${inner}\n${pad(indent)}]`;
-      }
-      const inner = value.map((el) => formatScalar(el)).join(', ');
-      return `[ ${inner} ]`;
-    }
-    if (value && typeof value === 'object') {
-      const keys = Object.keys(value).sort();
-      if (keys.length === 0) return '{}';
-      const lines = keys.map((k) => `${pad(indent + 2)}${k}: ${toHumanReadable((value as any)[k], indent + 2)}`);
-      return `{\n${lines.join('\n')}\n${pad(indent)}}`;
-    }
-    return formatScalar(value);
-  };

577-648: Component size: extract Solution and Submissions panels

These two panels are large and self-contained (syntax highlighting, copy actions, lists). Extracting into <SolutionsTab .../> and <SubmissionsTab .../> will reduce cognitive load in ProblemSolver and improve testability.

Happy to provide a quick refactor scaffold if you want it in this PR.

Also applies to: 650-749

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c5e64a and 78734a5.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (25)
  • .eslintrc.overrides.js (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/dev-test.yml (1 hunks)
  • CI_CD_README.md (1 hunks)
  • code-executor-api/server.js (3 hunks)
  • eslint.config.js (1 hunks)
  • package.json (2 hunks)
  • scripts/dev-start.sh (1 hunks)
  • src/components/AIChat.tsx (3 hunks)
  • src/components/Notes.tsx (1 hunks)
  • src/components/ui/command.tsx (1 hunks)
  • src/components/ui/textarea.tsx (1 hunks)
  • src/data/pythonSolutions.ts (1 hunks)
  • src/hooks/useChatSession.ts (2 hunks)
  • src/hooks/useProblems.ts (1 hunks)
  • src/hooks/useSubmissions.ts (1 hunks)
  • src/pages/ProblemSolver.tsx (9 hunks)
  • src/services/userAttempts.ts (2 hunks)
  • supabase/functions/ai-chat/index.ts (4 hunks)
  • tailwind.config.ts (1 hunks)
  • test-connection.js (0 hunks)
  • test-dynamic-problems.js (0 hunks)
  • test-judge0.js (0 hunks)
  • test-leetcode-style.js (0 hunks)
  • test-supabase-integration.js (0 hunks)
💤 Files with no reviewable changes (5)
  • test-judge0.js
  • test-connection.js
  • test-leetcode-style.js
  • test-supabase-integration.js
  • test-dynamic-problems.js
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/components/ui/command.tsx
  • src/components/Notes.tsx
  • src/components/ui/textarea.tsx
  • src/hooks/useProblems.ts
  • tailwind.config.ts
  • src/hooks/useSubmissions.ts
  • eslint.config.js
  • code-executor-api/server.js
  • .eslintrc.overrides.js
  • src/hooks/useChatSession.ts
  • src/services/userAttempts.ts
  • src/data/pythonSolutions.ts
  • src/components/AIChat.tsx
  • scripts/dev-start.sh
  • supabase/functions/ai-chat/index.ts
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/dev-test.yml

49-49: shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


57-57: shellcheck reported issue in this script: SC2034:warning:29:1: i appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/ci.yml

44-44: shellcheck reported issue in this script: SC2034:warning:12:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


95-95: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


104-104: shellcheck reported issue in this script: SC2034:warning:9:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


161-161: shellcheck reported issue in this script: SC2129:style:3:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


172-172: shellcheck reported issue in this script: SC2034:warning:27:1: i appears unused. Verify use (or export if used externally)

(shellcheck)


263-263: shellcheck reported issue in this script: SC2015:info:1:26: Note that A && B || C is not if-then-else. C may run when A is true

(shellcheck)

🪛 YAMLlint (1.37.1)
.github/workflows/dev-test.yml

[error] 13-13: trailing spaces

(trailing-spaces)


[error] 105-105: trailing spaces

(trailing-spaces)


[error] 112-112: no new line character at the end of file

(new-line-at-end-of-file)

🪛 markdownlint-cli2 (0.17.2)
CI_CD_README.md

8-8: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


42-42: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (2)
src/pages/ProblemSolver.tsx (2)

871-882: LGTM: expected/actual switched to compact JSON

Using toCompactJson here provides consistent, robust rendering with circular protection.


9-13: Dependencies confirmed in package.json

Both react-syntax-highlighter (line 52) and safe-stable-stringify (line 55) are declared under dependencies in the root package.json. No further action required.

… results

feat: add dev environment setup with CI/CD workflows and code solutions

chore: clean up debug logs, fix code analysis logic, and pin bun version to 1.1.3

fix: improve TypeScript types and use GitHub secrets for CI

- Add proper TypeScript interfaces for ReactMarkdown components
- Fix React hook dependencies in ProblemSolver component
- Add type-safe Monaco editor interface
- Use GitHub secrets instead of hardcoded credentials in CI workflow

chore: update CI workflow and improve dev-start script

- Upgrade actions/cache from v3 to v4 in CI workflow
- Enhance health check logic for frontend and API services with retries
- Update Node.js version from 18 to 20 in CI workflow
- Refactor environment file creation to use printf for better readability
- Improve cleanup handling in dev-start script for background processes
- Ensure proper signal handling for cleanup on exit

fix: remove gituh actions
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (8)
CI_CD_README.md (8)

8-8: Use a proper heading instead of bold (markdownlint MD036).
Switch emphasis to a heading for consistency and to satisfy markdownlint.

-**Comprehensive testing and deployment pipeline**
+#### Comprehensive testing and deployment pipeline

42-42: Use a proper heading instead of bold (markdownlint MD036).
Same issue as above for the dev workflow section.

-**Quick testing for development branches**
+#### Quick testing for development branches

27-31: Avoid integration test race conditions; wait for services.
Explicitly wait for health endpoints before running e2e checks to reduce flakiness.

Example:

npx wait-on -t 60000 http-get://localhost:3001/health http-get://localhost:5173
# then run integration checks

37-40: Tighten security audits and surface results.
Augment audits for signal and CI reliability.

  • Use: npm audit --omit=dev --audit-level=high --json
  • Consider OSV-Scanner: npx @ossf/osv-scanner -r .
  • Enable Dependabot alerts/security updates and fail CI on high/critical.

44-47: Prevent duplicate runs on main between CI and dev-test.
Current triggers include main for both workflows; scope dev-test to non-main to reduce noise.

YAML tweak:

on:
  push:
-   branches: [main, develop]
+   branches: [develop]
  pull_request:
-   branches: [main, develop]
+   branches: [develop]
# or keep triggers and gate:
jobs:
  dev:
    if: github.ref != 'refs/heads/main'

Also consider:

concurrency:
  group: dev-tests-${{ github.ref }}
  cancel-in-progress: true

65-72: Document making dev script executable and Windows note.
Avoid setup friction by clarifying execution bits and WSL usage.

Add:

chmod +x scripts/dev-start.sh
# Commit executable bit:
git update-index --chmod=+x scripts/dev-start.sh

Windows: run via WSL or provide a cross-platform npm script alternative.


128-131: Badge URLs: pin branch and replace placeholders.
Improve accuracy and avoid ambiguous badges.

-![CI/CD Pipeline](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci.yml/badge.svg)
-![Dev Tests](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/dev-test.yml/badge.svg)
+![CI/CD Pipeline](https://github.com/<org-or-user>/<repo>/actions/workflows/ci.yml/badge.svg?branch=main)
+![Dev Tests](https://github.com/<org-or-user>/<repo>/actions/workflows/dev-test.yml/badge.svg?branch=develop)

153-165: Make debug commands fail fast and reflect dev mode.
Use strict flags and dev script to mirror CI behavior.

-npm start
-curl http://localhost:3001/health
+npm run dev &
+sleep 2
+curl -fS http://localhost:3001/health

Or use wait-on for robustness:

npx wait-on -t 60000 http-get://localhost:3001/health
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78734a5 and bedd4c1.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (23)
  • .eslintrc.overrides.js (1 hunks)
  • CI_CD_README.md (1 hunks)
  • code-executor-api/server.js (3 hunks)
  • eslint.config.js (1 hunks)
  • package.json (2 hunks)
  • scripts/dev-start.sh (1 hunks)
  • src/components/AIChat.tsx (3 hunks)
  • src/components/Notes.tsx (1 hunks)
  • src/components/ui/command.tsx (1 hunks)
  • src/components/ui/textarea.tsx (1 hunks)
  • src/data/pythonSolutions.ts (1 hunks)
  • src/hooks/useChatSession.ts (2 hunks)
  • src/hooks/useProblems.ts (1 hunks)
  • src/hooks/useSubmissions.ts (1 hunks)
  • src/pages/ProblemSolver.tsx (9 hunks)
  • src/services/userAttempts.ts (2 hunks)
  • supabase/functions/ai-chat/index.ts (4 hunks)
  • tailwind.config.ts (1 hunks)
  • test-connection.js (0 hunks)
  • test-dynamic-problems.js (0 hunks)
  • test-judge0.js (0 hunks)
  • test-leetcode-style.js (0 hunks)
  • test-supabase-integration.js (0 hunks)
💤 Files with no reviewable changes (5)
  • test-judge0.js
  • test-leetcode-style.js
  • test-connection.js
  • test-dynamic-problems.js
  • test-supabase-integration.js
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • scripts/dev-start.sh
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/hooks/useProblems.ts
  • tailwind.config.ts
  • src/components/Notes.tsx
  • .eslintrc.overrides.js
  • src/components/ui/command.tsx
  • src/components/ui/textarea.tsx
  • eslint.config.js
  • code-executor-api/server.js
  • src/data/pythonSolutions.ts
  • src/services/userAttempts.ts
  • src/hooks/useChatSession.ts
  • src/hooks/useSubmissions.ts
  • src/components/AIChat.tsx
  • supabase/functions/ai-chat/index.ts
  • src/pages/ProblemSolver.tsx
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
CI_CD_README.md

8-8: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


42-42: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

… code in ProblemSolver component

- Replace inline function with useMemo for deduplicating submissions
- Remove unnecessary debug scroll area effect
- Simplify JSON stringification logic
@swoosh1337 swoosh1337 merged commit 044b14f into main Aug 10, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 13, 2025
swoosh1337 added a commit that referenced this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant