Skip to content

Preserve group name on push + drop Iterator.from from OrderedSvelteMap#1160

Merged
elemdos merged 1 commit into
mainfrom
fix/bootstrap-preserve-group-name
Jun 3, 2026
Merged

Preserve group name on push + drop Iterator.from from OrderedSvelteMap#1160
elemdos merged 1 commit into
mainfrom
fix/bootstrap-preserve-group-name

Conversation

@elemdos
Copy link
Copy Markdown
Collaborator

@elemdos elemdos commented Jun 3, 2026

Summary

  • Group name on pushsite.yaml only stores the group ID, so on a file→CMS push the server previously synthesized a name from the ID (humanizeGroupID) and overwrote whatever the user had set in the dashboard (e.g. clobbering "Clients" with "8Y17hao5jt2xmd8"). The CLI already sends the group's display name out-of-band as group_name; import.go now reads it and threads it into ensureBootstrapGroup. bootstrap.go only overwrites the existing group's name / index when those were explicitly provided.
  • OrderedSvelteMap — replace TC39 Iterator.from(...) with plain generators (*keys, *values, etc.) for runtime compatibility; use super.get inside the iterator to bypass reactive tracking during iteration.

Test plan

  • Push a site whose group has been renamed in the dashboard — group name stays put after the push.
  • Push a site to a brand-new group — group lands with the CLI-supplied label, not a humanized ID.
  • OrderedSvelteMap iteration (for…of, forEach, .keys() etc.) still works on a runtime without Iterator Helpers.

Summary by CodeRabbit

  • Bug Fixes

    • Site group names are now correctly preserved during bootstrap operations.
  • Improvements

    • Group display names are now properly resolved and maintained during site creation and synchronization.

- import.go now reads group_name from the form so the CLI's workspace
  label flows through to the server. ensureBootstrapGroup only
  overwrites an existing group's name when one was explicitly
  provided, so a file→CMS push no longer clobbers e.g. "Clients" with
  the humanized group ID.

- OrderedSvelteMap swaps Iterator.from (TC39 helpers, not in all
  runtimes) for plain generators. Also uses super.get inside the
  iterator to bypass reactive tracking during iteration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

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: 4f463933-cf23-4ac0-9444-f584ad3b4f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 27cfbbf and d2a61c7.

📒 Files selected for processing (3)
  • internal/bootstrap.go
  • internal/import.go
  • src/lib/pocketbase/OrderedSvelteMap.ts

📝 Walkthrough

Walkthrough

This PR preserves site group display names during bootstrap operations and refactors internal iteration logic. The bootstrap function now distinguishes between explicit name provision and ID-only calls, updating only the fields explicitly set. The import handler threads group display names into bootstrap calls for both site creation and sync. OrderedSvelteMap replaces its Iterator-based strategy with generator functions for consistent ordered traversal.

Changes

Implementation Updates

Layer / File(s) Summary
Group name preservation in bootstrap logic
internal/bootstrap.go
ensureBootstrapGroup computes nameProvided flag to track explicit name input and conditionally updates existing group name and index fields only when explicitly set, preventing unintended overwrites.
Group name integration in import handler
internal/import.go
Import handler extracts group_name from multipart form and passes it with group ID to ensureBootstrapGroup during site auto-creation and existing-site sync, replacing prior ID-only calls.
OrderedSvelteMap generator-based iteration
src/lib/pocketbase/OrderedSvelteMap.ts
OrderedSvelteMap reimplements ordered traversal using a private *iterator() generator and updates forEach, keys(), values(), and entries() to yield results in stored order rather than using Iterator.from() mapping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through code so clean,
Preserving names where they've been seen,
And iterators dance in ordered grace—
With generators keeping pace! ✨

🚥 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 accurately summarizes both main changes: preserving group name on push and removing Iterator.from from OrderedSvelteMap, matching the core objectives of the PR.
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 fix/bootstrap-preserve-group-name

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.

@elemdos elemdos merged commit 14bdad2 into main Jun 3, 2026
6 checks passed
@elemdos elemdos deleted the fix/bootstrap-preserve-group-name branch June 3, 2026 03:22
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