Repository navigation
fix(ui): offer only TUN stacks mihomo accepts - #2247
Merged
Merged
Conversation
The TUN stack select still offered LWIP, which mihomo dropped in 1.18. Picking it made PATCH /configs fail with "invalid tun stack", the error was swallowed, and after a reload the select matched no option. - Offer Mixed, gVisor, System and Mips, the values mihomo parses (constant/tun.go), and match the reported stack case-insensitively. - Keep an unknown reported stack visible as an extra option. - Surface a refused TUN save as a toast and put the form back to the backend value instead of leaving the unsaved choice selected. Closes MetaCubeX#2196
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
On the Config page the TUN stack select still offers
LWIP(config.vue#L115). mihomo removed the lwIP stack in 9fc1fc4 (first released in 1.18). It now acceptsgvisor,system,mixedand, since 1.19.31,mips(constant/tun.go).Choosing LWIP therefore makes
PATCH /configsfail with 400invalid tun stack. On a remote backend that error is dropped:saveTuncallsmutatewith no error handler (config.vue#L92-L94), so nothing happens and the select keeps showing LWIP.The value is also copied verbatim into the select (config.vue#L218, #L231). mihomo reports
Mips, which is not in the list, and the agent and profiles use lowercase (gvisor). In both cases the select matches no option and shows something other than what the kernel runs.Changes:
useTunConfig.tsexports the stack list,Mixed,gVisor,SystemandMips, in the casingGET /configsreports.normalizeTunStack()maps a reported stack onto its option regardless of case.mutateAsync). A refused change shows atunSaveFailedtoast with the error message, andconfig.vueputs the TUN form back to the backend config. Desktop mode is unchanged;useTunalready reports its errors.tunSaveFailedis added to all seven locales.packages/agent, thebuildTunConfigcomment and pass-through test now saymipsinstead oflwip.Closes #2196
Type of Change
Screenshots / Recordings
Not included. The only visible change is the option list (LWIP replaced by Mips) and an error toast on a refused save.
Checklist
pnpm lintpasses)pnpm typecheckpassesTesting Performed
Environment: Node 24.22.2 and pnpm 10.34.1, in a Linux container.
composables/__tests__/useTunConfig.spec.ts:Mixedfallback, unknown stacks staying visible, and refused or accepted remote saves for both the stack and the toggle.Mipsinstead ofLWIP.mainwith the new tests: 7 of 30 fail. After the fix: 30 of 30 pass.pnpm --filter @metacubexd/ui test:unit: 59 files, 687 tests pass. This includes the locale parity check.pnpm --filter @metacubexd/agent test: 16 files, 261 tests pass.pnpm --filter @metacubexd/ui typecheckandpnpm --filter @metacubexd/agent typecheck: no errors.--fix) on the changed UI files: clean.prettier --checkon all changed files: clean.Additional Notes
mips, and sing-box does not either. Selecting it there is refused like LWIP is today, but the error is now shown and the select goes back to the running stack.Mixed, as before.