Skip to content

fix(edit-page): Slug gets -1 appended when editing page#255

Merged
perber merged 7 commits intomainfrom
fix/254-slug-gets--1-appended-when-editing-page
Nov 1, 2025
Merged

fix(edit-page): Slug gets -1 appended when editing page#255
perber merged 7 commits intomainfrom
fix/254-slug-gets--1-appended-when-editing-page

Conversation

@perber
Copy link
Owner

@perber perber commented Nov 1, 2025

This offers us the possibility to avoid adding -1 to the slug if we just edit the page.

This offers us the possibility to avoid adding `-1` to the slug if we just edit the page.
Copilot AI review requested due to automatic review settings November 1, 2025 13:54
@perber perber linked an issue Nov 1, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for passing a currentID parameter when suggesting slugs, allowing the slug service to exclude the current page when checking for slug conflicts. This enables editing a page's title without forcing a slug change if the generated slug matches the page's existing slug.

  • Added currentID parameter throughout the slug suggestion pipeline (API, service, and UI components)
  • Modified slug conflict detection to exclude the current page being edited
  • Removed the initialTitle check in slug suggestion logic
  • Added test coverage for the new behavior

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ui/leafwiki-ui/src/lib/api/pages.ts Added currentId parameter to suggestSlug function signature
ui/leafwiki-ui/src/features/page/SlugInputWithSuggestion.tsx Accepts and passes currentId parameter; removed initialTitle comparison
ui/leafwiki-ui/src/features/page/EditPageMetadataDialog.tsx Made currentId required and passes it to SlugInputWithSuggestion
ui/leafwiki-ui/src/features/editor/PageEditor.tsx Provides page?.id as currentId to the dialog
internal/http/api/suggest_slug.go Extracts and passes currentID query parameter
internal/wiki/wiki.go Updated SuggestSlug to accept and pass currentID parameter
internal/wiki/wiki_test.go Updated test calls with empty string for currentID
internal/core/tree/slug_service.go Modified conflict detection to exclude current page by ID
internal/core/tree/slug_service_test.go Updated tests and added new test case for same-slug scenario

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

perber and others added 2 commits November 1, 2025 14:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@perber perber requested a review from Copilot November 1, 2025 14:04
@perber perber force-pushed the fix/254-slug-gets--1-appended-when-editing-page branch from cd161d4 to 74abd18 Compare November 1, 2025 14:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

ui/leafwiki-ui/src/features/page/SlugInputWithSuggestion.tsx:69

  • The initialTitle variable is included in the dependency array but is no longer used in the effect logic (removed from the condition on line 38). This is dead code that should be removed from the dependency array.
    initialTitle,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

perber and others added 2 commits November 1, 2025 15:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@perber perber requested a review from Copilot November 1, 2025 14:19
@perber perber changed the title fix(edit-page): add current id to slug generation fix(edit-page): Slug gets -1 appended when editing page Nov 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@perber perber merged commit 2139973 into main Nov 1, 2025
4 checks passed
@perber perber deleted the fix/254-slug-gets--1-appended-when-editing-page branch November 1, 2025 14:26
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.

Slug gets -1 appended when editing page

2 participants