feat(desktop): show and reuse last used server URL in Setup Wizard (#5659)

# Description of Changes

This pull request enhances the server selection experience in the setup
wizard by remembering and displaying the last used server URL. Users can
now quickly reuse their previous server connection, improving usability
and reducing repetitive input.

**Server selection improvements:**

* The last used server URL is now stored in `localStorage` and
automatically displayed as a quick-select button in the
`ServerSelection` component, allowing users to easily reconnect to their
previous server.
[[1]](diffhunk://#diff-3a9a7d483f3f7789dbe410067f4401aea5898ad6692755c63e7787585b923151R19-R25)
[[2]](diffhunk://#diff-3a9a7d483f3f7789dbe410067f4401aea5898ad6692755c63e7787585b923151R212-R223)
[[3]](diffhunk://#diff-3a9a7d483f3f7789dbe410067f4401aea5898ad6692755c63e7787585b923151R38)
* A new translation string `useLast` was added to
`frontend/public/locales/en-GB/translation.toml` to support the "Last
used server" button label.

<img width="1282" height="832" alt="image"
src="https://github.com/user-attachments/assets/6f8a6d3a-9f6b-4bcb-9470-da3ad50a4409"
/>

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
Ludy 2026-02-06 11:44:42 +01:00 committed by GitHub
parent 62d2819213
commit dc6daaad0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -6564,6 +6564,7 @@ link = "or connect to a self-hosted account"
title = "Connect to Server"
subtitle = "Enter your self-hosted server URL"
testing = "Testing connection..."
useLast = "Last used server: {{serverUrl}}"
[setup.server.type]
saas = "Stirling PDF SaaS"

View File

@ -16,12 +16,13 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
const [testing, setTesting] = useState(false);
const [testError, setTestError] = useState<string | null>(null);
const [securityDisabled, setSecurityDisabled] = useState(false);
const serverUrl = localStorage.getItem('server_url') || '';
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Normalize and validate URL
let url = customUrl.trim().replace(/\/+$/, '');
let url = customUrl.trim().replace(/\/+$/, '') || serverUrl;
if (!url) {
setTestError(t('setup.server.error.emptyUrl', 'Please enter a server URL'));
@ -34,6 +35,7 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
url = `https://${url}`;
setCustomUrl(url); // Update the input field
}
localStorage.setItem('server_url', url);
// Validate URL format
try {
@ -207,6 +209,21 @@ export const ServerSelection: React.FC<ServerSelectionProps> = ({ onSelect, load
</Alert>
)}
{serverUrl && (
<div className="navigation-link-container">
<button
type="button"
className="navigation-link-button"
disabled={testing || loading}
onClick={() => {
setCustomUrl(serverUrl);
}}
>
{t('setup.server.useLast', 'Last used server: {{serverUrl}}', { serverUrl: serverUrl })}
</button>
</div>
)}
<Button
type="submit"
loading={testing || loading}