Native proxy settings#2827
Conversation
Co-authored-by: tim2zg <59140326+tim2zg@users.noreply.github.com>
…-e9fc06269a7b Fix TypeScript error TS2345 in settings.ts: Add type assertion for desktopProxyConfig
Langugaes
- Added proxy authentication handling in the Electron main process. - Introduced `getLastAppliedConfig` function to retrieve the last applied proxy configuration. - Enhanced the proxy preload script to include a resize window feature. - Updated the proxy window HTML to improve UI with a modern design and better accessibility. - Implemented secure password storage for proxy credentials. - Refactored proxy configuration handling to ensure proper validation and error handling. - Improved the settings management for proxy configurations, including reading and writing to secure storage.
…elds and documentation
|
|
|
Related Documentation No published documentation to review for changes on this repository. |
There was a problem hiding this comment.
Can this be cts instead and be transpiled by typescript into the lib dir instead of avoiding typescript? I.e follow the path of the main preload script
t3chguy
left a comment
There was a problem hiding this comment.
This is exciting, but a few points
Additionally, looks like the autoUpdater won't respect these proxy settings which is problematic without a warning to the user
| @@ -0,0 +1,378 @@ | |||
| <!-- | |||
| Copyright 2026 New Vector Ltd. | |||
There was a problem hiding this comment.
We are not New Vector anymore, this should be your copyright anyway
| @@ -0,0 +1,96 @@ | |||
| /* | |||
| Copyright 2026 New Vector Ltd. | |||
| @@ -0,0 +1,154 @@ | |||
| /* | |||
| Copyright 2026 New Vector Ltd. | |||
There was a problem hiding this comment.
I think this will want to use Compound components for UI, so may need more complexity and likely to be within the main UI rather than entirely standalone. Needs design
| <h1>Network Proxy</h1> | ||
|
|
||
| <div class="section"> | ||
| <span class="section-title">Connection Mode</span> | ||
| <label class="radio-option" | ||
| ><input type="radio" name="mode" id="proxy-mode-system" value="system" checked /> Use system proxy | ||
| settings</label | ||
| > | ||
| <label class="radio-option" | ||
| ><input type="radio" name="mode" id="proxy-mode-direct" value="direct" /> No proxy (direct | ||
| connection)</label | ||
| > | ||
| <label class="radio-option" | ||
| ><input type="radio" name="mode" id="proxy-mode-custom" value="custom" /> Manual configuration</label | ||
| > | ||
| </div> |
There was a problem hiding this comment.
tried it but not sure if it's right
| <input id="proxy-password" type="password" autocomplete="off" /> | ||
| </div> | ||
| </div> | ||
| <div class="helper-text">Passwords are stored securely in the system keychain.</div> |
There was a problem hiding this comment.
I don't think this is true with safeStorage, a single random string is stored in system keychain and other secrets are encrypted symmetrically using it. Additionally the user may have no keychain where this message becauses confusing.
You checked this box but the CLA does not appear to be signed. Could you also include screenshots of what the UI you added looks like? |
…elds and documentation
…g/element-desktop into feat/native-proxy-settings
…g/element-desktop into feat/native-proxy-settings
…g/element-desktop into feat/native-proxy-settings
…g/element-desktop into feat/native-proxy-settings
…g/element-desktop into feat/native-proxy-settings
Added a notice |
Also, the CLA is not okay because I tried using GitHub Copilot at the beginning and didn’t reset the history. GitHub now lists Copilot as a contributor. |
|
Hello, thanks for your contribution @tim2zg! In order to integrate this feature into the product, the form you've proposed will need to be presented in a modal (rather than in a separate browser tab). Then there will be 2 places from which the user can access this modal: From the Welcome screen, and from Settings. Here are visuals to help illustrate:
Ideally, please provide 1.) the modal and form contents and 2.) the settings section block. As for UI components, use those provide by our Compound Design System at https://compound.element.io Here's a quick cheat sheet: |
|
Hey, thanks for the feedback. Would this then be added to the main element app repo or injected into it from the wrapper? And would I then need to open up a second pull request there? Best regards |
|
Yes the UI code would live in element-web & communicate over IPC, there's already a wrapper for settings to handle the IPC communication for you. In the future it may be possible to have the UI code live on the element-desktop side and be injected as a module but we aren't there yet. In the near future element-desktop will be re-merged into the element-web (mono)repo to make contributions like this easier. |
|
Thanks for working on this! This feature is highly anticipated by many users, including myself, as it significantly improves the desktop experience. Looking forward to seeing this merged. Is there anything the community can help with to speed up the process? @tim2zg |
|
Hello @fjh1997, Thank you. I will open another PR on the web repo shortly. I could use some help testing! Best regards, |
|
@tim2zg Awesome! Let me know when it's ready for testing. |
|
I'm just going to put this back into draft while it's still waiting on other parts. |
- Explicitly resolve and apply system proxies in 'system' mode to avoid HTTP bypass - Fix proxyRules separator to use semicolons per Chromium standard - Ensure consistent focus rings in NetworkProxyModal for Compound inputs - Fix password box outline vanishing when clicked in the proxy modal - Remove obsolete proxy proposal documentation
- Extracted resolveSystemProxy to reduce cognitive complexity - Replaced global with globalThis for better standards compliance - Used optional chaining and nullish coalescing where appropriate - Removed redundant type assertions and duplicate imports
|
UI PR: element-hq/element-web#32804 |
4012b9a to
221271f
Compare
- Use optional chaining in proxyConfig check - Remove redundant void operators - Fix redundant type assertions in settings - Correct TS error in certificate-error listener
|
@fjh1997 Please feel free to test:) |
|
Hi @tim2zg, I’m a user in mainland China, so I need a proxy to log in to Matrix at all. I tested your desktop PR together with the corresponding element-web PR locally. The proxy UI does appear after login, but I still ran into a few usability problems:
diff --git a/packages/shared-components/src/settings/NetworkProxyView/NetworkProxyView.tsx b/packages/shared-components/src/settings/NetworkProxyView/NetworkProxyView.tsx
--- a/packages/shared-components/src/settings/NetworkProxyView/NetworkProxyView.tsx
+++ b/packages/shared-components/src/settings/NetworkProxyView/NetworkProxyView.tsx
@@
-import { _t } from "../../utils/I18nApi";
+import { _t } from "../../utils/i18n";
diff --git a/apps/web/src/settings/Settings.tsx b/apps/web/src/settings/Settings.tsx
--- a/apps/web/src/settings/Settings.tsx
+++ b/apps/web/src/settings/Settings.tsx
@@
+ "desktopProxyConfig": {
+ supportedLevels: [SettingLevel.PLATFORM],
+ displayName: _td("settings|network_proxy|title"),
+ default: {
+ mode: "system",
+ },
+ },
diff --git a/apps/web/src/i18n/strings/en_EN.json b/apps/web/src/i18n/strings/en_EN.json
--- a/apps/web/src/i18n/strings/en_EN.json
+++ b/apps/web/src/i18n/strings/en_EN.json
@@
+ "network_proxy": {
+ "connection_mode": "Connection mode",
+ "manual_configuration": "Manual configuration",
+ "mode_custom_selected": "Manual proxy configuration is enabled.",
+ "mode_direct_selected": "Direct connection is enabled. No proxy will be used.",
+ "mode_system_selected": "Using the system proxy configuration.",
+ "no_proxy_direct": "No proxy (direct connection)",
+ "no_proxy_for_comma_separated": "No proxy for",
+ "port": "Port",
+ "proxy_config_encrypted_system_storage": "Proxy password is stored in the system credential store when available.",
+ "proxy_host": "Proxy host",
+ "proxy_settings_updates_warning": "Changes apply to new network requests after saving.",
+ "settings_button": "Configure proxy",
+ "title": "Network Proxy",
+ "use_system_proxy": "Use system proxy"
+ },
diff --git a/src/proxy.ts b/src/proxy.ts
--- a/src/proxy.ts
+++ b/src/proxy.ts
@@
- const scheme = cfg.scheme ?? "http";
- parts.push(`${scheme}=${scheme}://${auth}${cfg.host}:${cfg.port}`);
+ const scheme = cfg.scheme ?? "http";
+ parts.push(`${scheme}://${auth}${cfg.host}:${cfg.port}`);
I think the proxy config should survive logout. For example:
For me, the main issue is that recovery is too hard when network access is broken. I think the login/welcome flow should still provide a way to change proxy and homeserver settings, similar to Telegram. For reference, this is roughly how I built and tested the two PRs locally: git clone https://github.com/element-hq/element-web.git
git clone https://github.com/element-hq/element-desktop.git
cd element-web
git fetch origin pull/32804/head:pr-32804
git checkout pr-32804
pnpm install
cp ../element-desktop/element.io/release/config.json ./apps/web/config.json
sed -i 's|from "../../utils/I18nApi"|from "../../utils/i18n"|' \
packages/shared-components/src/settings/NetworkProxyView/NetworkProxyView.tsx
npx nx build element-web
cd ../element-desktop
git fetch origin pull/2827/head:pr-2827
git checkout pr-2827
pnpm install
rm -f webapp
ln -s ../element-web/apps/web/webapp ./webapp
pnpm run asar-webapp
pnpm run build
sudo apt install -y ./dist/element-desktop_1.12.12_amd64.debPlease let me know if this is not the correct way to combine the two PRs for testing. |
|
Sorry but you will need to merge these changes into element-hq/element-web#32804 |





Description
This PR implements a native "Network Proxy" settings window, allowing users to configure their proxy connection directly within the application UI instead of relying on command-line arguments or environment variables.
Changes
defaultSession.Store.Solution for Issue: element-hq/element-web#32407
Checklist
public/exportedsymbols have accurate TSDoc documentation.