Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Profile setup progress was opaque and sequential. Users couldn't distinguish between cached profile reuse and fresh creation, multiple profiles were created serially, and there was no visibility into profiles coming online.

Changes

Progress indicators

  • get_relay_profile() now returns (profile, is_cached) tuple
  • Progress messages display: "Setting up profiles: X/Y (cached: A, creating: B)"
  • Online progress shows: "Waiting for N profile(s) to come online: X/N" with real-time updates

Parallelization

  • Receiver profile setup runs in concurrent threads
  • Profile lookup/creation serialized under ProfileMaker.lock to prevent race conditions
  • start_io() (the I/O-bound bottleneck) executes outside lock for true parallelization

Event handling

  • ERROR events displayed during profile setup with detailed messages
  • WARNING events logged during profile setup
  • Progress bar continues updating as profiles come online

Terminology

  • Renamed AccountMakerProfileMaker, get_relay_accountget_relay_profile
  • Updated all user-facing strings and variables
  • Preserved deltachat-rpc API: get_all_accounts(), add_account(), accounts_dir unchanged

Optimized thread safety

  • Removed unnecessary lock from _add_online() (Python list.append() is atomic)
  • Kept lock only in get_relay_profile() to prevent duplicate profile selection
  • deltachat-rpc-server handles all API calls thread-safely

Implementation

class ProfileMaker:
    def __init__(self, dc):
        self.dc = dc
        self.online = []
        self.lock = threading.Lock()  # Only for profile selection
    
    def get_relay_profile(self, domain):
        with self.lock:
            # Find cached profile or create new one (prevent race)
            # ...
        # I/O runs outside lock - parallelizable
        self._add_online(profile)
        return profile, is_cached
    
    def wait_all_online(self):
        # Show progress: "Waiting for N profile(s) to come online: X/N"
        # Display ERROR/WARNING events as they occur

Threading strategy: serialize fast atomic operations (profile lookup/creation), parallelize slow I/O operations (start_io()). Minimal locking leverages Python's atomic operations and deltachat-rpc-server's thread safety.

Original prompt

during account setup make the progress spinner indicate better which accounts are already configured and cached, and which are freshly created.

parallelize the setup of fresh accounts
rename "account" to "profile" but take care to not change the API to deltachat-rpc objects.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 24, 2026 14:15
…tion

- Rename AccountMaker to ProfileMaker and all related variables
- Add is_cached detection in get_relay_profile method
- Update progress messages to show cached vs creating status
- Parallelize receiver profile setup using threads
- Keep deltachat-rpc API calls unchanged (get_all_accounts, add_account)

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
- Add lock to ProfileMaker to prevent race conditions during profile lookup/creation
- Move start_io() call outside lock to allow true parallelization
- Fix nonlocal declaration placement in setup_receiver_profile
- Add comments explaining thread-safety approach

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
- Clarify that cached profiles are those found in existing accounts
- Explain that multiple profiles per domain are supported (for receivers)
- Document why start_io() is called outside the lock (parallelization)
- Improve comments in setup_receiver_profile to explain behavior

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve account setup spinner and parallelize fresh account setup Enhance profile setup: add cached/creating indicators and parallelize creation Jan 24, 2026
Copilot AI requested a review from hpk42 January 24, 2026 14:21
@hpk42
Copy link
Contributor

hpk42 commented Jan 24, 2026

@copilot print progress bar for accounts coming online, and print the precise number instead of "all profiles". Show any error output that arrives via events. Read https://py.delta.chat for documentation of events.

- Display precise count: "Waiting for N profile(s) to come online: X/N"
- Show ERROR events during profile setup with detailed messages
- Show WARNING events during profile setup
- Update progress counter in real-time as profiles come online
- Remove redundant "Waiting for all profiles" generic message

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot print progress bar for accounts coming online, and print the precise number instead of "all profiles". Show any error output that arrives via events. Read https://py.delta.chat for documenta...

Done in commit 6f789d0. The wait_all_online method now:

  • Shows precise count: "Waiting for N profile(s) to come online: X/N"
  • Updates progress in real-time as each profile comes online
  • Displays ERROR events with detailed messages
  • Displays WARNING events during setup

Example output:

# Setting up profiles: 3/3 (cached: 1, creating: 2) - Complete!
# Waiting for 3 profile(s) to come online: 0/3
# Waiting for 3 profile(s) to come online: 1/3
# Waiting for 3 profile(s) to come online: 2/3
# Waiting for 3 profile(s) to come online: 3/3

If errors occur during setup, they're displayed inline:

✗ ERROR during profile setup: <error message>
⚠ WARNING during profile setup: <warning message>

Copilot AI and others added 2 commits January 24, 2026 14:50
- Remove lock from _add_online: Python list.append() is atomic
- Keep lock in get_relay_profile: prevents race condition where multiple threads select same cached profile
- Add detailed comments explaining why lock is needed in get_relay_profile
- Clarify that deltachat-rpc-server handles all API calls thread-safely
- Extract print_progress helper to reduce code duplication

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
- Clarify that len() and list copy are atomic operations in Python
- Document that timeout handling is done at caller level
- Explain that list copy avoids concurrent modification issues

Co-authored-by: hpk42 <73579+hpk42@users.noreply.github.com>
Copilot AI changed the title Enhance profile setup: add cached/creating indicators and parallelize creation Enhance profile setup: add cached/creating indicators, parallelize creation, and show online progress Jan 24, 2026
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