Skip to content

fix(welcome): show new database groups without restart (#1704)#1709

Merged
datlechin merged 1 commit into
mainfrom
fix-1704-new-group-not-shown
Jun 17, 2026
Merged

fix(welcome): show new database groups without restart (#1704)#1709
datlechin merged 1 commit into
mainfrom
fix-1704-new-group-not-shown

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #1704.

Problem

Creating a new database group did not show it in the connection list until a full app restart.

Root cause

The welcome list renders WelcomeViewModel.treeItems, which is built only by rebuildTree(). The .newGroup sheet completion persisted the group and set vm.groups, but never called rebuildTree(). Since the view model is @Observable, only views that read a property that was written get invalidated, and treeItems was never rewritten, so the list stayed stale until loadGroups() ran at the next launch. This is the documented "WelcomeViewModel tree rebuild" invariant, violated for the groups side.

The one path that worked was Move to Group > New Group..., because it called moveConnections, which happens to rebuild.

Fix

  • Added WelcomeViewModel.createGroup(name:color:parentId:), mirroring the other group mutators (confirmRenameGroup, updateGroupColor, moveGroup) that all end in rebuildTree(). The reload-and-guard also stops the group from being expanded or moved into when addGroup silently rejects it (duplicate name, depth cap, cycle).
  • The sheet completion in WelcomeWindowView now calls vm.createGroup(...) instead of reaching into GroupStorage.shared and mutating vm.groups from the view body, which is what let it drift out of step in the first place.

Tests

New WelcomeViewModelTests with isolated storage:

  • a created group appears in treeItems immediately (the regression)
  • a subgroup expands both parent and child
  • a duplicate name adds no second node

Notes

  • swiftlint lint --strict clean on the changed files.
  • The ConnectionGroupPicker copy of CreateGroupSheet (connection form) is unaffected: it reloads its own list locally.

@datlechin datlechin merged commit caeea76 into main Jun 17, 2026
2 of 3 checks passed
@datlechin datlechin deleted the fix-1704-new-group-not-shown branch June 17, 2026 15:12

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e78a16211a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let group = ConnectionGroup(name: name, color: color, parentId: parentId)
groupStorage.addGroup(group)
groups = groupStorage.loadGroups()
guard groups.contains(where: { $0.id == group.id }) else { return }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear pending move when group creation fails

When this is reached from Move to Group > New Group..., pendingMoveToNewGroup is already populated. If addGroup rejects the new group (for example a duplicate sibling name), this early return leaves that pending list set while the sheet still dismisses; the next unrelated successful group creation will hit the later pendingMoveToNewGroup block and move the old connections into that new group unexpectedly. Clear the pending move on the failure path or only retain it while the sheet remains active.

Useful? React with 👍 / 👎.

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.

New database groups wont show until full app restart

1 participant