Skip to content

Fix resolve() with BUILD_BASE_PATH and hash routes#1014

Merged
FyreByrd merged 8 commits into
sillsdev:mainfrom
chrisvire:fix/resolve-hash-routes
Jun 18, 2026
Merged

Fix resolve() with BUILD_BASE_PATH and hash routes#1014
FyreByrd merged 8 commits into
sillsdev:mainfrom
chrisvire:fix/resolve-hash-routes

Conversation

@chrisvire

@chrisvire chrisvire commented Jun 18, 2026

Copy link
Copy Markdown
Member

This was causing creating notes to fail since a full refresh was caused and loss of state.

Summary by CodeRabbit

  • Refactor
    • Centralized URL/path resolution in a shared utility and updated navigation across components and pages to use it, improving consistency for hash-based routes.
  • Bug Fixes
    • Corrected the default navigation link for the Icon Card to point to the proper text route.
  • Chores
    • Improved TypeScript linting by enabling project-wide type information.

@chrisvire chrisvire requested a review from FyreByrd June 18, 2026 02:39
@coderabbitai

coderabbitai Bot commented Jun 18, 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

Run ID: 5ca80aff-bc2d-4871-9463-68cf8d2b7328

📥 Commits

Reviewing files that changed from the base of the PR and between 881cd4e and a3dd874.

📒 Files selected for processing (27)
  • eslint.config.js
  • src/lib/components/BookSelector.svelte
  • src/lib/components/BottomNavigationBar.svelte
  • src/lib/components/HistoryCard.svelte
  • src/lib/components/IconCard.svelte
  • src/lib/components/Navbar.svelte
  • src/lib/components/NoteDialog.svelte
  • src/lib/components/PlanStopDialog.svelte
  • src/lib/components/ScriptureViewSofria.svelte
  • src/lib/components/Sidebar.svelte
  • src/lib/components/TextSelectionToolbar.svelte
  • src/lib/components/VerseOnImage.svelte
  • src/lib/navigate/index.ts
  • src/lib/utils/paths.ts
  • src/routes/+page.svelte
  • src/routes/bookmarks/+page.svelte
  • src/routes/contents/[id]/+page.svelte
  • src/routes/highlights/+page.svelte
  • src/routes/image/upload/+page.svelte
  • src/routes/lexicon/+layout.svelte
  • src/routes/lexicon/+page.svelte
  • src/routes/notes/+page.svelte
  • src/routes/plans/+page.svelte
  • src/routes/plans/[id]/+page.svelte
  • src/routes/plans/[id]/settings/+page.svelte
  • src/routes/search/[collection]/[[savedResults]]/+page.svelte
  • src/routes/text/+page.svelte
✅ Files skipped from review due to trivial changes (5)
  • src/lib/components/PlanStopDialog.svelte
  • src/lib/components/BookSelector.svelte
  • src/routes/search/[collection]/[[savedResults]]/+page.svelte
  • src/lib/components/Navbar.svelte
  • src/routes/notes/+page.svelte
🚧 Files skipped from review as they are similar to previous changes (21)
  • src/routes/plans/[id]/settings/+page.svelte
  • src/routes/+page.svelte
  • src/routes/bookmarks/+page.svelte
  • src/lib/components/TextSelectionToolbar.svelte
  • src/lib/utils/paths.ts
  • src/routes/contents/[id]/+page.svelte
  • src/routes/plans/+page.svelte
  • src/routes/image/upload/+page.svelte
  • src/routes/highlights/+page.svelte
  • src/lib/components/NoteDialog.svelte
  • src/lib/components/VerseOnImage.svelte
  • src/routes/plans/[id]/+page.svelte
  • src/lib/components/IconCard.svelte
  • src/lib/navigate/index.ts
  • src/lib/components/BottomNavigationBar.svelte
  • src/routes/lexicon/+page.svelte
  • src/lib/components/ScriptureViewSofria.svelte
  • src/routes/text/+page.svelte
  • src/routes/lexicon/+layout.svelte
  • src/lib/components/HistoryCard.svelte
  • src/lib/components/Sidebar.svelte

📝 Walkthrough

Walkthrough

A new resolve wrapper is added to src/lib/utils/paths.ts that delegates to SvelteKit's $app/paths resolve with generic typing and applies hash-prefix normalization. ESLint configuration is updated to enable TypeScript type-aware linting on src/**/*.ts files. All 26 existing consumers of resolve from $app/paths across components, navigation utilities, and route files are migrated to import from the new utility. IconCard.svelte also changes its default href target from /#/text to /text, and a redundant @ts-expect-error comment is removed from contents/[id]/+page.svelte.

Changes

Custom resolve wrapper and site-wide migration

Layer / File(s) Summary
New resolve utility
src/lib/utils/paths.ts
Exports generically typed resolve<T extends string>(path: HashFreePath<T>): ResolvedPathname wrapping SvelteKit's $app/paths resolve with pathname normalization to insert / before hash segments.
ESLint TypeScript configuration
eslint.config.js
Adds top-level ESLint config for src/**/*.ts files with languageOptions.parserOptions.projectService: true to enable type-aware linting rules.
Navigation utility and components migration
src/lib/navigate/index.ts, src/lib/components/BottomNavigationBar.svelte, src/lib/components/HistoryCard.svelte, src/lib/components/IconCard.svelte, src/lib/components/Navbar.svelte, src/lib/components/NoteDialog.svelte, src/lib/components/PlanStopDialog.svelte, src/lib/components/ScriptureViewSofria.svelte, src/lib/components/Sidebar.svelte, src/lib/components/TextSelectionToolbar.svelte, src/lib/components/VerseOnImage.svelte, src/lib/components/BookSelector.svelte
Switches resolve import from $app/paths to $lib/utils/paths across all lib components and the navigate helper. IconCard.svelte additionally changes its default href from /#/text to /text.
Route pages and layouts migration
src/routes/+page.svelte, src/routes/bookmarks/+page.svelte, src/routes/contents/[id]/+page.svelte, src/routes/dev/icons/+page.svelte, src/routes/highlights/+page.svelte, src/routes/image/upload/+page.svelte, src/routes/lexicon/+layout.svelte, src/routes/lexicon/+page.svelte, src/routes/notes/+page.svelte, src/routes/plans/+page.svelte, src/routes/plans/[id]/+page.svelte, src/routes/plans/[id]/settings/+page.svelte, src/routes/search/[collection]/[[savedResults]]/+page.svelte, src/routes/text/+page.svelte
Switches resolve import from $app/paths to $lib/utils/paths in all route pages and layouts. contents/[id]/+page.svelte removes a @ts-expect-error comment alongside the import migration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • FyreByrd

Poem

🐇 Hoppity-hop through paths we go,
A wrapper wraps resolve below!
The # gets a / friend,
Hash routes are healed from end to end.
One helper rules them all, hooray —
The rabbit tidied imports today! 🌿

🚥 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 directly and clearly describes the main change: fixing the resolve() function to work correctly with BUILD_BASE_PATH and hash routes.
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 unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/lib/components/BookSelector.svelte

Oops! Something went wrong! :(

ESLint: 9.39.4

The requested operation requires ESLint to serialize configuration data,
but the configuration key "0.markup" contains a function value,
which cannot be serialized.

Please double-check your configuration for errors.

If you still have problems, please stop by https://eslint.org/chat/help to chat
with the team.

src/lib/components/BottomNavigationBar.svelte

Oops! Something went wrong! :(

ESLint: 9.39.4

The requested operation requires ESLint to serialize configuration data,
but the configuration key "0.markup" contains a function value,
which cannot be serialized.

Please double-check your configuration for errors.

If you still have problems, please stop by https://eslint.org/chat/help to chat
with the team.

src/lib/components/HistoryCard.svelte

Oops! Something went wrong! :(

ESLint: 9.39.4

The requested operation requires ESLint to serialize configuration data,
but the configuration key "0.markup" contains a function value,
which cannot be serialized.

Please double-check your configuration for errors.

If you still have problems, please stop by https://eslint.org/chat/help to chat
with the team.

  • 21 others

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/utils/paths.ts`:
- Line 21: The hash normalization in the return statement of the
svelteKitResolve function call uses an unconditional replace pattern that
transforms already-normalized paths like `/#/text` into `//#/text`. Modify the
regex pattern in the replace method to only add the `/` prefix when `#` appears
at the start of the string or is not already preceded by `/`. This can be
achieved using a negative lookbehind assertion or by matching the context before
the `#` character.
🪄 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: 74568f18-3775-425a-9724-088de2889531

📥 Commits

Reviewing files that changed from the base of the PR and between 59640a4 and 881cd4e.

📒 Files selected for processing (26)
  • src/lib/components/BottomNavigationBar.svelte
  • src/lib/components/HistoryCard.svelte
  • src/lib/components/IconCard.svelte
  • src/lib/components/Navbar.svelte
  • src/lib/components/NoteDialog.svelte
  • src/lib/components/PlanStopDialog.svelte
  • src/lib/components/ScriptureViewSofria.svelte
  • src/lib/components/Sidebar.svelte
  • src/lib/components/TextSelectionToolbar.svelte
  • src/lib/components/VerseOnImage.svelte
  • src/lib/navigate/index.ts
  • src/lib/utils/paths.ts
  • src/routes/+page.svelte
  • src/routes/bookmarks/+page.svelte
  • src/routes/contents/[id]/+page.svelte
  • src/routes/dev/icons/+page.svelte
  • src/routes/highlights/+page.svelte
  • src/routes/image/upload/+page.svelte
  • src/routes/lexicon/+layout.svelte
  • src/routes/lexicon/+page.svelte
  • src/routes/notes/+page.svelte
  • src/routes/plans/+page.svelte
  • src/routes/plans/[id]/+page.svelte
  • src/routes/plans/[id]/settings/+page.svelte
  • src/routes/search/[collection]/[[savedResults]]/+page.svelte
  • src/routes/text/+page.svelte

Comment thread src/lib/utils/paths.ts
@chrisvire

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@FyreByrd FyreByrd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You missed one in BookSelector.svelte.

We also use asset from $app/paths, but I think this is not subject to the same problem, so should be fine.

Comment thread eslint.config.js
- added comment to eslint config
- replace missed usage of $app/paths
@FyreByrd FyreByrd merged commit 2818c41 into sillsdev:main Jun 18, 2026
4 checks passed
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.

2 participants