Offer to init repo when adding existing repo fails (#1799)#2417
Offer to init repo when adding existing repo fails (#1799)#2417SaurabhCodesAI wants to merge 2 commits intoborgbase:masterfrom
Conversation
|
@m3nu can u review? |
|
If we add this, why not remove the distinction between new/existing repo? |
@m3nu |
08f0b5c to
32cfb5b
Compare
Probes with borg info first, connects or offers to init accordingly. Closes borgbase#1799
32cfb5b to
1f63ede
Compare
|
@m3nu please review? |
m3nu
left a comment
There was a problem hiding this comment.
PR Review
Design Concern: UX Regression for "Add Existing Repo" Flow
The old ExistingRepoWindow had a deliberately simpler UI:
- Single password field (no confirmation needed — you're entering an existing password)
- No encryption selector (encryption is auto-detected from the repo)
- Title: "Connect to existing Repository"
The unified AddRepoWindow always shows dual password fields with min 9-char validation, an encryption selector dropdown, and a generic "Add Repository" title. When a user just wants to connect to an existing repo, the encryption selector and password confirmation are confusing and irrelevant.
Suggestion: Consider hiding the encryption combobox and confirm password field initially, and only showing them if the user accepts the "init" prompt.
Bug: RepoWindow.validate(self) — Explicit Parent Call Bypasses Polymorphism
def run(self):
if not RepoWindow.validate(self): # <-- explicit parent class call
returnThis deliberately bypasses AddRepoWindow.validate() (which includes self.passwordInput.validate()) to skip password validation during the probe phase. This is fragile and non-idiomatic — readers expect self.validate(), and future modifications to the validation chain won't behave as expected.
Suggestion: Extract a _validate_repo_fields() method for URL/name validation, separate from validate().
UX Issue: Password Validation Timing for Init Path
When the probe fails and the user accepts "Initialize a new one?", the code calls self.passwordInput.validate(). But the user likely only entered a password in the first field (expecting to connect to an existing repo). They'll get a confusing "Passwords must be identical" error with no guidance about why confirmation is suddenly needed.
Suggestion: Show a clear message when switching from probe to init mode, e.g. "Please enter and confirm a password for the new repository."
Test Issue: test_repo_add_name_validation Assertion Change
# Old:
('test_repo_name', ''), # valid repo name — no error
# New:
('test_repo_name', 'Checking repository…'), # valid repo name — shows progressThe parameter is called error_text but 'Checking repository…' is not an error — it's a progress message. This masks the behavior change and makes the test assert on transient status rather than validation state.
Missing Error Detail in Status Messages
When the probe fails with a non-"does not exist" error (e.g., "Connection refused", "Permission denied"), the actual borg error from result['errors'] is discarded in favor of generic "Unable to add your repository." Including the borg error message would help users diagnose the issue.
Minor: Translation Contexts Orphaned
The i18n .ts files (12+ languages) reference ExistingRepoWindow as a translation context. Removing the class orphans those translations.
What Looks Good
- The probe-then-init approach is a solid UX improvement over making users guess
- Error string detection (
'does not exist','is not a valid repository') covers known borg messages - Good test coverage with parametrized error strings, accept/decline paths, unrelated errors, and probe success
- Clean removal of
ExistingRepoWindowwith no dangling references in production code _init_repo()correctly delegates toself.run_resultfor result handling- Integration test properly mocks
QMessageBox.questionfor the new confirmation step
@m3nu Thanks, these are all fair points. Learned a few things here I'll fix them up:
I will Push fixes shortly, will keep it as a separate commit so it's easy to review. |
|
@m3nu i would need your guidance one thing i am unsure about for point 3, once the user says yes to init, |
|
You can decide it. You just look at it from a user perspective. |
sure. |
|
@m3nu sorry for the delay i spent the week going through the codebase to get fully up to speed before the GSoC contribution window opens... Just pushed a new commit with the fixes: Hid init widgets by default. |
Description
When
ExistingRepoWindowgets a "does not exist" or "is not a valid repository" error from borg, prompt the user to initialize a new repo at that location. If accepted, openAddRepoWindowpre filled with the URL and name from the original dialog. If declined, fall through to the normal error message.Changes:
ExistingRepoWindow: addedinit_requestedsignal andrun_result()override that detects repo not found errors and shows a confirmation dialogRepoTab: connectedinit_requested, added_open_init_from_existing()which opensAddRepoWindowpre filled and sets local/remote mode correctlyNote: #1816 addresses the same issue but has been inactive since mid 2024. This is an independent implementation using a signal-based approach with test coverage.
Related Issue
Closes #1799
Motivation and Context
Users who try to add a non existent or uninitialized path via "Existing Repository" get a generic "Unable to add your repository" error with no guidance. This change detects that specific failure and offers to open the init dialog instead, reducing confusion between the two repo-adding workflows.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.