[PR #2530] [MERGED] fix: detect and resolve position conflicts during task creation #10056

Closed
opened 2026-04-23 09:22:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2530
Author: @tink-bot
Created: 4/2/2026
Status: Merged
Merged: 4/3/2026
Merged by: @kolaente

Base: mainHead: fix-task-reorder-position


📝 Commits (5)

  • d6227ac fix: add position conflict resolution for batch-inserted positions
  • 6c511d3 fix: detect and resolve position conflicts during task creation
  • 37ca6b2 fix: use InDelta for float comparison in tests
  • 5c46395 refactor: use nested map for position conflict tracking
  • ee46121 test: assert position existence instead of conditional skip

📊 Changes

3 files changed (+155 additions, -1 deletions)

View changed files

📝 pkg/models/task_position.go (+35 -0)
📝 pkg/models/task_position_test.go (+115 -1)
📝 pkg/models/tasks.go (+5 -0)

📄 Description

When tasks are created, setTaskInBucketInViews() assigns positions via calculateNewPositionForTask() without checking for conflicts. If two tasks end up with the same position value in a view, their order scrambles on reload because the database has no uniqueness constraint on positions.

This adds a conflict-detection step after bulk-inserting positions during task creation, reusing the existing findPositionConflicts() and resolveTaskPositionConflicts() logic that already works in the update path.

Fixes #2495, fixes #2400


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2530 **Author:** [@tink-bot](https://github.com/tink-bot) **Created:** 4/2/2026 **Status:** ✅ Merged **Merged:** 4/3/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-task-reorder-position` --- ### 📝 Commits (5) - [`d6227ac`](https://github.com/go-vikunja/vikunja/commit/d6227ace10eb743c35b782e960ea4acb1283ffbf) fix: add position conflict resolution for batch-inserted positions - [`6c511d3`](https://github.com/go-vikunja/vikunja/commit/6c511d36d36990d801a72f39aa44f5a8fc192cf7) fix: detect and resolve position conflicts during task creation - [`37ca6b2`](https://github.com/go-vikunja/vikunja/commit/37ca6b232e13ed8a3787d60587a4658dbfa1a889) fix: use InDelta for float comparison in tests - [`5c46395`](https://github.com/go-vikunja/vikunja/commit/5c46395d68ec91b814f4327517e4772c2c5669b7) refactor: use nested map for position conflict tracking - [`ee46121`](https://github.com/go-vikunja/vikunja/commit/ee461212342f3e66ec9d2a0dd8ef18ea24828f54) test: assert position existence instead of conditional skip ### 📊 Changes **3 files changed** (+155 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `pkg/models/task_position.go` (+35 -0) 📝 `pkg/models/task_position_test.go` (+115 -1) 📝 `pkg/models/tasks.go` (+5 -0) </details> ### 📄 Description When tasks are created, `setTaskInBucketInViews()` assigns positions via `calculateNewPositionForTask()` without checking for conflicts. If two tasks end up with the same position value in a view, their order scrambles on reload because the database has no uniqueness constraint on positions. This adds a conflict-detection step after bulk-inserting positions during task creation, reusing the existing `findPositionConflicts()` and `resolveTaskPositionConflicts()` logic that already works in the update path. Fixes #2495, fixes #2400 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 09:22:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#10056