mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5381] [MERGED] fix(desktop): window lifecycle for instance switch #5180
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5180
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5381
Author: @CuriousCorrelation
Created: 9/9/2025
Status: ✅ Merged
Merged: 9/22/2025
Merged by: @jamesgeorge007
Base:
next← Head:desktop-fix-window-lifecycle-management📝 Commits (2)
aba26c0fix(desktop): window lifecycle for instance switch2b51f5achore: resolve lint errors📊 Changes
3 files changed (+56 additions, -19 deletions)
View changed files
📝
packages/hoppscotch-common/package.json(+1 -1)📝
packages/hoppscotch-common/src/services/instance-switcher.service.ts(+53 -8)📝
pnpm-lock.yaml(+2 -10)📄 Description
This resolves window accumulation during instance switching by implementing proper window lifecycle management using Tauri's WebviewWindow APIs.
Closes FE-1015
Issue
When switching between server instances and vendored instances,
previous windows remained open instead of closing automatically.
This creates multiple windows for what should be a single-window
experience and eventually blocks further instance switching (> 3 at the
moment) mainly due to window label conflicts.
The new
closemethod was introduced as part of the portable phase-2,and while it works for the portable version, this patch reinforces the
backwards compatibility for current switcher until the complete
switcher service rewrite planned for upcoming phases.
The current issue is a byproduct of that refactor that manifests as:
Cause & Context
The
InstanceSwitcherServicewas missing window lifecycle management.While the service handled connection state and data persistence, it did
not close the current window after successfully loading a new instance,
as oppose to the similar service implementation in
Home.vue.The correct sequence:
Fix
getCurrentWebviewWindow,getAllWebviewWindows)Updated both
connectToVendoredInstance()andconnectToServerInstance()to call window cleanup after successfulload operations using fire-and-forget (no
await) pattern to avoidexecution context issues.
Testing
Implementation Notes
Uses non-awaited
closeCurrentWindow()calls because window closing must happen from the current execution
context before it terminates. Awaiting the close operation would create
timing issues.
Uses
getCurrentWebviewWindow()andgetAllWebviewWindows()instead of deprecated v1/v2 APIs, withsync
labelproperty access.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.