Skip to content

refactor: crypto UUID substitution - #13

Merged
AxelUser merged 5 commits into
mainfrom
feat/crypto-uuid-substitution
Jun 3, 2026
Merged

refactor: crypto UUID substitution#13
AxelUser merged 5 commits into
mainfrom
feat/crypto-uuid-substitution

Conversation

@AxelUser

@AxelUser AxelUser commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Logo now automatically switches between dark and light variants based on theme preference.
  • Refactor

    • Simplified CV creation flow (removed template-based initialization).
    • Improved ID generation with a new createId utility.
    • Updated default/sample CV content.
  • Style

    • Consolidated module imports across components and tests.
  • Documentation

    • E2E testing strategy doc updated.
  • Tests

    • Updated test fixtures and E2E expectations to match new sample data.

AxelUser added 3 commits June 3, 2026 00:12
… use it

- Added a randomUUID function to utils.ts for generating UUIDs in non-secure contexts.
- Updated CV creation in multiple components to utilize the new randomUUID function instead of crypto.randomUUID for consistency and compatibility.
- Added `nanoid` package for unique ID generation.
- Refactored CV creation functions to utilize `createId` instead of `randomUUID`.
- Updated multiple components to ensure consistent ID generation for CVs.
- Removed the deprecated `createCVFromTemplate` function and its associated template file.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

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

Run ID: 57f0ffd6-7c20-4b4d-b09e-ea1d4f257030

📥 Commits

Reviewing files that changed from the base of the PR and between 54a3912 and 07fe0d3.

📒 Files selected for processing (2)
  • e2e/editor.spec.ts
  • src/lib/components/dev/dummy-cv.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/components/dev/dummy-cv.ts

📝 Walkthrough

Walkthrough

This PR introduces a new ID generation utility based on nanoid, refactors CV creation from a template-based API to a simpler parameter-driven approach, updates all CV creation entry points, replaces dummy data, switches logo dark-mode handling to CSS classes, and consolidates imports across components and tests.

Changes

CV Creation API and Infrastructure

Layer / File(s) Summary
ID Generation Infrastructure
src/lib/id.ts, package.json, src/lib/types/cv.ts
Adds createId() utility using nanoid with runtime detection, declares nanoid ^5.1.11 dependency, and updates createObjectId() to use createId() instead of crypto.randomUUID().
CV Creation API Refactor
src/lib/services/cv/create.ts, src/lib/services/cv/templates.ts
Replaces createCVFromTemplate(id, name, template) with createCV({ name, id? }) that generates IDs internally; removes CVTemplate, CVTemplateBlock, and CLASSIC_TEMPLATE exports.
CV Creation Integration
src/lib/components/dashboard/new-cv-button.svelte, src/routes/+page.svelte, src/lib/features/tailoring/create-tailored.ts
Updates CV creation entry points: new-cv-button and home page now use createCV({ name }) without manual UUID generation; tailored CV creation uses createId().
Dummy CV Content Update
src/lib/components/dev/dummy-cv.ts
Refactors createDummyCV() to use new createCV API and replaces all test fixture data (person, contacts, highlights, skills, job history, projects, education) with "Dwight Schrute"–themed content.

UI and Component Updates

Layer / File(s) Summary
Logo Dark Mode via CSS Classes
src/lib/components/ui/logo/logo.svelte
Logo now renders both light and dark variants simultaneously with Tailwind dark: utility classes, removing dependency on mode-watcher.
Block and UI Component Import Consolidations
src/lib/components/blocks/*, src/lib/components/ui/editable-list/editable-list.svelte, src/lib/components/ui/tag-input/tag-input.svelte, src/stories/blocks/helpers/*, src/stories/ui/helpers/*
Consolidates scattered createObjectId value and type imports into single statements across many component and story files.
Test and Fixture Import Consolidations
src/lib/features/export/generate.test.ts, src/lib/features/export/preprocess.test.ts, src/lib/features/export/themes/classic/classic.test.ts, src/lib/features/tailoring/_fixtures.ts, src/lib/features/tailoring/locate.test.ts, src/lib/features/tailoring/present.test.ts
Consolidates createObjectId and type imports in test and fixture files into single import statements.
E2E Test Strategy Documentation
docs/decisions/ADR-004-e2e-test-strategy.md
Updates ADR-004 to reflect that non-editor E2E tests seed via production createCV constructor instead of createCVFromTemplate.

🎯 3 (Moderate) | ⏱️ ~25 minutes

"A rabbit hops through files with glee,
Retiring templates, creating with ease,
nanoid secures each brand-new ID,
Dark modes via CSS—hopping spree! 🐰✨"

🚥 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 PR title 'refactor: crypto UUID substitution' accurately reflects the main objective: replacing crypto.randomUUID() with a new createId() utility throughout the codebase.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/crypto-uuid-substitution

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/components/dev/dummy-cv.ts (1)

8-169: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Recompute blockHashes after populating the dummy blocks.

createCV() hashes the empty default blocks up front, then this helper overwrites nearly every block and returns without refreshing cv.blockHashes. Because src/lib/e2e-bridge.ts:15-92 persists createDummyCV() as-is, seeded CVs will carry hash metadata that no longer matches their content.

Suggested fix
+import { computeBlockHashes } from '$lib/features/tailoring/hash';
 import { createObjectId, type CV, type Tag } from '$lib/types/cv';
 import { createCV } from '$lib/services/cv/create';
@@
 export function createDummyCV(): CV {
 	const cv = createCV({ name: 'Dummy — Dwight Schrute' });
@@
 	cv.blocks.education.value = [
@@
 	];
 
+	cv.blockHashes = computeBlockHashes(cv.blocks);
 	return cv;
 }
🤖 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/lib/components/dev/dummy-cv.ts` around lines 8 - 169, The dummy CV
currently overwrites nearly all blocks after calling createCV() but never
updates cv.blockHashes, leaving stale hashes; after populating the blocks in
createDummyCV(), recompute and assign fresh block hashes to cv.blockHashes by
invoking the same hashing routine used by createCV (e.g., call
computeBlockHashes(cv) or the existing helper that createCV uses) so the
persisted seeded CVs have matching blockHashes.
🤖 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/lib/components/dev/dummy-cv.ts`:
- Around line 59-128: The job-history seed in cv.blocks.jobHistory.value was
changed to Dwight-themed entries which breaks the editor E2E fixture that
expects Nimbus Labs, Cobalt Financial, and Bright Pixel Studio (see
e2e/editor.spec.ts:67-88); either restore those original entries in
cv.blocks.jobHistory.value (using the same object shape with createObjectId()
and tags(...) for skills) or, if intentional, update the E2E spec to assert the
new companies so both code and tests stay in sync.

---

Outside diff comments:
In `@src/lib/components/dev/dummy-cv.ts`:
- Around line 8-169: The dummy CV currently overwrites nearly all blocks after
calling createCV() but never updates cv.blockHashes, leaving stale hashes; after
populating the blocks in createDummyCV(), recompute and assign fresh block
hashes to cv.blockHashes by invoking the same hashing routine used by createCV
(e.g., call computeBlockHashes(cv) or the existing helper that createCV uses) so
the persisted seeded CVs have matching blockHashes.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06e9fb83-7cf5-4e71-b869-dc135921aa53

📥 Commits

Reviewing files that changed from the base of the PR and between 159c7ce and 54a3912.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (36)
  • docs/decisions/ADR-004-e2e-test-strategy.md
  • package.json
  • src/lib/components/blocks/contacts-block.svelte
  • src/lib/components/blocks/education-block.svelte
  • src/lib/components/blocks/job-history-block.svelte
  • src/lib/components/blocks/projects-block.svelte
  • src/lib/components/blocks/skills-block.svelte
  • src/lib/components/dashboard/new-cv-button.svelte
  • src/lib/components/dev/dummy-cv.ts
  • src/lib/components/ui/editable-list/editable-list.svelte
  • src/lib/components/ui/logo/logo.svelte
  • src/lib/components/ui/tag-input/tag-input.svelte
  • src/lib/features/export/generate.test.ts
  • src/lib/features/export/preprocess.test.ts
  • src/lib/features/export/themes/classic/classic.test.ts
  • src/lib/features/tailoring/_fixtures.ts
  • src/lib/features/tailoring/create-tailored.ts
  • src/lib/features/tailoring/locate.test.ts
  • src/lib/features/tailoring/present.test.ts
  • src/lib/id.ts
  • src/lib/services/cv/create.ts
  • src/lib/services/cv/templates.ts
  • src/lib/types/cv.ts
  • src/routes/+page.svelte
  • src/stories/blocks/helpers/ContactsWrapper.svelte
  • src/stories/blocks/helpers/EducationWrapper.svelte
  • src/stories/blocks/helpers/FullNameWrapper.svelte
  • src/stories/blocks/helpers/HighlightsWrapper.svelte
  • src/stories/blocks/helpers/JobHistoryWrapper.svelte
  • src/stories/blocks/helpers/LocationWrapper.svelte
  • src/stories/blocks/helpers/PositionWrapper.svelte
  • src/stories/blocks/helpers/ProjectsWrapper.svelte
  • src/stories/blocks/helpers/SkillsWrapper.svelte
  • src/stories/ui/helpers/BlockWrapperWrapper.svelte
  • src/stories/ui/helpers/EditableListWrapper.svelte
  • src/stories/ui/helpers/TagInputWrapper.svelte
💤 Files with no reviewable changes (1)
  • src/lib/services/cv/templates.ts

Comment thread src/lib/components/dev/dummy-cv.ts
@AxelUser
AxelUser merged commit 8f4d3b0 into main Jun 3, 2026
6 checks passed
@AxelUser
AxelUser deleted the feat/crypto-uuid-substitution branch June 3, 2026 07:27
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