Repository navigation
Keep Ethernet hero during Wi-Fi connect and follow active route #20708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emirb
wants to merge
1
commit into
quattro
Choose a base branch
from
fix/network-panel-dual-interface
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| import QtQuick | ||
| import Quickshell | ||
| import Quickshell.Io | ||
| import Quickshell.Networking | ||
| import qs.Commons | ||
| import qs.Commons as Commons | ||
| import "mocks" | ||
| import "network" as Network | ||
| import "network/Model.js" as Model | ||
|
|
||
| // Verifies dual-interface behavior in Panel.qml: | ||
| // 1. Connecting Wi-Fi while Ethernet is primary keeps switchingNetwork false | ||
| // and preserves the Ethernet hero. | ||
| // 2. Docking local-only Ethernet while Wi-Fi-only stays on Wi-Fi without | ||
| // flashing Ethernet, and unrelated route events are ignored. | ||
| // 3. Main-table route changes flip kind and icon even when a VPN tunnel exists. | ||
| // 4. Switching Wi-Fi while Wi-Fi owns the route sets switchingNetwork true. | ||
| ShellRoot { | ||
| id: test | ||
| property bool failed: false | ||
| function check(ok, message) { | ||
| if (!ok) { | ||
| failed = true | ||
| console.log("RESULT fail " + message) | ||
| } | ||
| } | ||
|
|
||
| component Net: QtObject { | ||
| property string name | ||
| property bool connected: false | ||
| property bool known: true | ||
| property bool stateChanging: false | ||
| property real signalStrength: 0.8 | ||
| property int security: WifiSecurityType.Open | ||
| signal connectionFailed(int reason) | ||
| function connect() {} | ||
| function connectWithPsk(psk) {} | ||
| function disconnect() {} | ||
| function forget() {} | ||
| } | ||
|
|
||
| property QtObject wired: QtObject { | ||
| property int type: DeviceType.Wired | ||
| property string name: "test-eth" | ||
| property bool connected: true | ||
| property var networks: ({ values: [] }) | ||
| } | ||
| property Net office: Net { name: "OfficeWiFi"; signalStrength: 0.8 } | ||
| property Net cafe: Net { name: "Cafe"; signalStrength: 0.6 } | ||
|
|
||
| property var afterRouteWrite: null | ||
| Process { | ||
| id: routeSetter | ||
| onExited: { | ||
| var cb = test.afterRouteWrite | ||
| test.afterRouteWrite = null | ||
| if (cb) cb() | ||
| } | ||
| } | ||
|
|
||
| function setRoute(mode, notifyMode, cb) { | ||
| afterRouteWrite = cb || null | ||
| routeSetter.command = notifyMode ? ["test-set-route", mode, notifyMode] : ["test-set-route", mode] | ||
| routeSetter.running = true | ||
| } | ||
|
|
||
| Item { | ||
| Network.Panel { | ||
| id: panel | ||
| bar: QtObject { | ||
| property color foreground: Commons.Color.foreground | ||
| property color barForeground: Commons.Color.foreground | ||
| property color urgent: Commons.Color.urgent | ||
| property string fontFamily: Style.font.family | ||
| property string position: "top" | ||
| property int barSize: 24 | ||
| property bool vertical: false | ||
| property bool foregroundAnimationEnabled: false | ||
| property var activePopout: null | ||
| function requestPopout(owner) { activePopout = owner } | ||
| function releasePopout(owner) { activePopout = null } | ||
| function registerClickTarget(target) {} | ||
| function unregisterClickTarget(target) {} | ||
| function hideTooltip(target) {} | ||
| function showTooltip(target, text) {} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| property var steps: [ | ||
| function() { | ||
| NetworkMock.wifi.connected = false | ||
| NetworkMock.wifi.networks = { values: [office, cafe] } | ||
| NetworkMock.devices = { values: [wired, NetworkMock.wifi] } | ||
| panel.refresh() | ||
| }, | ||
| function() { | ||
| check(panel.kind === "ethernet", "Ethernet-only reports kind=ethernet (got " + panel.kind + ")") | ||
| panel.connectDirectly("OfficeWiFi") | ||
| check(!panel.switchingNetwork, "connecting Wi-Fi while Ethernet is primary keeps switchingNetwork false") | ||
| panel.testEnsureContent() | ||
| check(panel.testTitle.text.indexOf("Ethernet") === 0, "Ethernet hero stays Ethernet during Wi-Fi connect (got " + panel.testTitle.text + ")") | ||
| check(panel.testMeta.text !== "CONNECTING...", "Ethernet hero meta does not flip to CONNECTING... (got " + panel.testMeta.text + ")") | ||
| office.connected = true | ||
| NetworkMock.wifi.connected = true | ||
| check(panel.kind === "ethernet", "Wi-Fi connecting over Ethernet does not flash kind (got " + panel.kind + ")") | ||
| }, | ||
| function() { | ||
| check(panel.dualConnected && panel.kind === "ethernet", "working Ethernet stays kind=ethernet with Wi-Fi connected (got " + panel.kind + ")") | ||
| wired.connected = false | ||
| setRoute("wifi", false) | ||
| }, | ||
| function() { | ||
| check(panel.kind === "wifi", "Wi-Fi-only reports kind=wifi") | ||
| wired.connected = true | ||
| check(panel.kind === "wifi", "docking local-only Ethernet while on Wi-Fi does not flash Ethernet (got " + panel.kind + ")") | ||
| }, | ||
| function() { | ||
| check(panel.dualConnected && panel.kind === "wifi", "route check confirms Wi-Fi stays active (got " + panel.kind + ")") | ||
| setRoute("ethernet", "noise") | ||
| }, | ||
| function() { | ||
| check(panel.kind === "wifi", "unrelated subnet and table-52 events do not flip kind (got " + panel.kind + ")") | ||
| setRoute("vpn-eth", "notify") | ||
| }, | ||
| function() { | ||
| // Wait for routeSettle + routeProc. | ||
| }, | ||
| function() { | ||
| check(panel.kind === "ethernet", "working Ethernet wins over Wi-Fi even with VPN tunnel (got " + panel.kind + ")") | ||
| check(!panel.canShareWifi, "QR share stays hidden when kind is ethernet") | ||
| check(panel.testTitle.text.indexOf("Ethernet") === 0, "Ethernet title shows immediately on failover (got " + panel.testTitle.text + ")") | ||
| setRoute("wifi", "notify") | ||
| }, | ||
| function() { | ||
| // Wait for routeSettle + routeProc. | ||
| }, | ||
| function() { | ||
| check(panel.kind === "wifi" && panel.icon === Model.wifiIconFor(80), "failover back to Wi-Fi updates kind and bar icon (got " + panel.kind + ")") | ||
| panel.connectDirectly("Cafe") | ||
| check(panel.switchingNetwork, "switching Wi-Fi while Wi-Fi owns the route sets switchingNetwork true") | ||
| office.connected = false | ||
| NetworkMock.wifi.connected = false | ||
| panel.clearNetworkAction() | ||
| }, | ||
| function() { | ||
| check(!panel.dualConnected && panel.kind === "ethernet", "Ethernet-only restores kind=ethernet (got " + panel.kind + ")") | ||
| if (!test.failed) console.log("RESULT pass") | ||
| Qt.quit() | ||
| } | ||
| ] | ||
| property int step: 0 | ||
|
|
||
| Timer { | ||
| interval: 400 | ||
| running: test.step < test.steps.length | ||
| repeat: true | ||
| onTriggered: test.steps[test.step++]() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With both links connected and a full-tunnel VPN active,
finishRoute()selects the physical link, butdetailsProcstill runsomarchy-network-status --verbosewithout choosing an interface. That helper followsip route get 1.1.1.1, so the hero can name Wi-Fi while the address and transfer counts belong to the VPN. The helper also reports the tunnel as Ethernet, which hides Wi-Fi sharing throughcanShareWifi.Keep the winning interface from the route lookup and use it for the displayed details.
Knowledge Base Used: Captive portal and network connectivity