Skip to content

refactor: move useCipherWorker hook to hooks directory - #959

Open
gauri9368gupta-maker wants to merge 1 commit into
csxark:mainfrom
gauri9368gupta-maker:refactor/consolidate-hooks
Open

refactor: move useCipherWorker hook to hooks directory#959
gauri9368gupta-maker wants to merge 1 commit into
csxark:mainfrom
gauri9368gupta-maker:refactor/consolidate-hooks

Conversation

@gauri9368gupta-maker

@gauri9368gupta-maker gauri9368gupta-maker commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR moves useCipherWorker from lib/hooks/ to the centralized hooks/ directory and updates all affected imports.

The change consolidates React hooks under the project-level hooks/ directory while preserving the existing worker implementation and behavior.

Changes Made

  • Moved:

    • lib/hooks/useCipherWorker.ts
    • hooks/useCipherWorker.ts
  • Updated all component imports referencing useCipherWorker.

  • Updated the unit test import path.

  • Corrected the worker type import path:

    • ../../types/worker
    • ../types/worker
  • Preserved the existing hook implementation and worker functionality.

  • Removed the old lib/hooks/useCipherWorker.ts location through the Git rename.

Files Updated

  • app/benchmark/page.tsx
  • components/avalanche/AvalancheVisualizer.tsx
  • components/challenge/ChallengeMode.tsx
  • components/challenge/DailyQuiz.tsx
  • components/cipher/CipherLayout.tsx
  • components/compare/CipherComparisonPanel.tsx
  • components/tests/CipherIntegrationDashboard.tsx
  • components/workers/WorkerCommunicationDashboard.tsx
  • hooks/useCipherWorker.ts
  • tests/unit/hooks/useCipherWorker.test.ts

Testing

Test Command

npm test -- tests/unit/hooks/useCipherWorker.test.ts

Result

5/7 tests passed.

Passed:

  • Initializes worker and handles successful message execution
  • Handles explicit abort using AbortSignal
  • Memoizes/caches cipher results
  • Bypasses cache when requested
  • Respects the LRU cache limit

Two existing behavioral assertions currently fail:

  1. The automatic-abort test expects the previous worker's terminate() method to be called.
  2. The timeout test expects error to equal the string WORKER_TIMEOUT, while the current implementation exposes the structured error { code: 'WORKER_TIMEOUT' }.

These failures are unrelated to the import/path consolidation performed by this PR.

Additional Checks

git diff --cached --check

Result: Passed — no whitespace errors.

Checklist

  • Moved useCipherWorker to the centralized hooks/ directory
  • Updated all affected imports
  • Corrected the relative worker type import
  • Updated unit test import path
  • Removed the old hook location
  • Preserved existing hook functionality
  • Ran the targeted unit tests
  • Ran git diff --cached --check
  • Changes committed successfully
  • Full test suite passing
  • CI checks passing

Commit

51c7f5d refactor: move useCipherWorker hook to hooks directory

Expected Outcome

useCipherWorker is now located consistently with the project's other React hooks, reducing the previous lib/hooks duplication and making the hook easier to discover and maintain.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of cipher-related features by correcting internal module references.
    • Ensured cipher processing continues to use the correct worker location across benchmark, challenge, comparison, and visualization experiences.
  • Tests

    • Updated automated coverage to reflect the corrected cipher worker integration.

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@gauri9368gupta-maker is attempting to deploy a commit to the csxark's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🎉 Thank You for Your Contribution

Hello @gauri9368gupta-maker,

Thank you for submitting a Pull Request to CryptoViz. We appreciate the time and effort you've invested in contributing to the project.

Your Pull Request has been received successfully and will be reviewed by the maintainers as soon as possible.

📋 Pull Request Checklist

  • ✅ Linked the related issue
  • ✅ No merge conflicts
  • ✅ Synced with the latest main branch
  • ✅ Build passes successfully
  • ✅ All tests pass

Ensuring these requirements are met helps streamline the review process and enables maintainers to review your contribution more efficiently.

❤️ Support CryptoViz

If you find CryptoViz helpful, consider supporting the project by:

  • ⭐ Starring the repository
  • 🍴 Forking the repository
  • 👤 Following Ark on GitHub
  • 💼 Connecting on LinkedIn
  • 🌐 Visiting the Portfolio

Your support helps increase the project's visibility and encourages continued development. Thank you for being a part of the CryptoViz community!

Thank you once again for contributing to CryptoViz. We appreciate your support and look forward to reviewing your contribution.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b50fa13-d759-427f-8ef3-618db3d5da3b

📥 Commits

Reviewing files that changed from the base of the PR and between e4a6af1 and 51c7f5d.

📒 Files selected for processing (10)
  • app/benchmark/page.tsx
  • components/avalanche/AvalancheVisualizer.tsx
  • components/challenge/ChallengeMode.tsx
  • components/challenge/DailyQuiz.tsx
  • components/cipher/CipherLayout.tsx
  • components/compare/CipherComparisonPanel.tsx
  • components/tests/CipherIntegrationDashboard.tsx
  • components/workers/WorkerCommunicationDashboard.tsx
  • hooks/useCipherWorker.ts
  • tests/unit/hooks/useCipherWorker.test.ts

📝 Walkthrough

Walkthrough

The PR relocates useCipherWorker to the top-level hooks/ path, updates its internal module and worker paths, and changes all listed consumers and tests to use the new import location.

Changes

Cipher worker relocation

Layer / File(s) Summary
Update hook module paths
hooks/useCipherWorker.ts
The hook now references relocated cipher, type, utility, and worker modules.
Update hook consumers and test
app/benchmark/page.tsx, components/{avalanche,challenge,cipher,compare,tests,workers}/*, tests/unit/hooks/useCipherWorker.test.ts
Components and the unit test now import useCipherWorker from hooks/.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Possibly related PRs

Suggested labels: ECSoC26, ECSoC26-L1

Suggested reviewers: csxark

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes moving the useCipherWorker hook to the hooks directory, which is the main change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch refactor/consolidate-hooks
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@csxark

csxark commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Hi @gauri9368gupta-maker, resolve the merge conflicts

@csxark csxark added ECSoC26 Elite Coders Summer of Code 2026 and removed needs review labels Aug 9, 2026
@gauri9368gupta-maker

Copy link
Copy Markdown
Contributor Author

Hi @gauri9368gupta-maker, resolve the merge conflicts

sure i will do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26 Elite Coders Summer of Code 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants