Skip to content

Fix repeated terminal launches when reopening GodotHub with Godot running - #162

Merged
RykoTheDev merged 1 commit into
RykoTheDev:mainfrom
hanmi255:main
Sep 4, 2026
Merged

Fix repeated terminal launches when reopening GodotHub with Godot running#162
RykoTheDev merged 1 commit into
RykoTheDev:mainfrom
hanmi255:main

Conversation

@hanmi255

@hanmi255 hanmi255 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a Windows issue where reopening GodotHub while a Godot project was
still running could cause a terminal window to repeatedly open and close.

The same session-tracking behavior is now unified across Windows and Unix
platforms, including Linux and macOS.

Problem

The issue could be reproduced as follows:

  1. Start GodotHub.
  2. Open a Godot project.
  3. Enable Close application on project open, or close GodotHub manually.
  4. Leave the Godot project running.
  5. Start GodotHub again.

Under the affected implementation, GodotHub recovered the stale project session
using platform-specific process detection. The monitoring path could repeatedly
launch external process-query commands such as PowerShell, WMIC, or ps.

On Windows, these helper-process launches could become visible as terminal
windows, producing this loop:

terminal starts
→ terminal closes immediately
→ terminal starts again
→ terminal closes immediately
→ repeat

Closing the Godot process stopped the loop because the stale-session monitor no
longer had an active process to track.

Root Cause

Process discovery and process monitoring were mixed together:

  • Unix used path-based polling.
  • Windows used PID checks together with external process discovery.
  • Recovered sessions did not share one platform-neutral process-tracking model.
  • External process-query commands could be invoked repeatedly during monitoring.

Solution

This PR introduces a dedicated cross-platform process module.

Process tracking

  • Process discovery is performed once during stale-session recovery.
  • Recovered sessions are tracked by PID on both Windows and Unix.
  • Normal monitoring uses direct PID liveness checks.
  • Windows uses OpenProcess and GetExitCodeProcess.
  • Unix uses kill(pid, 0).
  • If a PID appears to have exited, the process identity is revalidated once
    against the stored Godot project path.
  • Process termination verifies the PID/project identity before killing it.

Test organization

Process tests were moved out of projects.rs and organized as:

src-tauri/tests/
├── common/process.rs
├── windows/process.rs
└── unix/process.rs

Expected Result

  • Reopening GodotHub while Godot is still running no longer starts a repeated
    terminal open/close loop.
  • The normal process-monitoring loop does not repeatedly launch PowerShell,
    WMIC, or ps.
  • Windows, Linux, and macOS use the same PID-based session lifecycle.
  • Existing project launch, close, stale-session recovery, and time tracking
    behavior remains unchanged.

Verification

Passed locally:

  • cargo test --manifest-path src-tauri/Cargo.toml
  • cargo check --manifest-path src-tauri/Cargo.toml --target x86_64-pc-windows-msvc
  • bun run lint
  • bunx tsc --noEmit

The Windows-specific tests run on the current Windows environment. The Unix
tests are selected with cfg(unix) and should be run on Linux/macOS CI or
native development environments.

Files Changed

  • src-tauri/src/process.rs
  • src-tauri/src/projects.rs
  • src-tauri/src/terminal.rs
  • src-tauri/src/lib.rs
  • src-tauri/Cargo.toml
  • src-tauri/Cargo.lock
  • src-tauri/tests/common/process.rs
  • src-tauri/tests/windows/process.rs
  • src-tauri/tests/unix/process.rs

Fix repeated terminal open/close behavior when GodotHub is restarted
while a Godot project is still running.

Root cause:
- After GodotHub exited, stale Godot sessions were recovered using
  platform-specific tracking logic.
- Unix used path polling, while Windows mixed PID checks and external
  process discovery.
- Reopening GodotHub while Godot was still running could cause the
  monitoring loop to repeatedly launch process-query commands.
- On Windows, those helper processes could create visible terminal
  windows, resulting in a loop of terminal startup and immediate close.

Changes:
- Add a dedicated cross-platform process module.
- Use one-time process discovery during stale-session recovery.
- Track recovered Godot processes by PID on Windows and Unix.
- Use Windows OpenProcess/GetExitCodeProcess and Unix kill(pid, 0)
  for liveness checks.
- Revalidate the PID and project path once when the PID appears to exit.
- Verify process identity before terminating a recovered process.
- Remove repeated ps/PowerShell/WMIC calls from the normal monitoring loop.
- Remove duplicated process APIs from terminal.rs.
- Move process parser tests out of projects.rs.
- Organize tests into common, windows, and unix directories.
- Add Windows-only windows-sys dependencies.
@RykoTheDev
RykoTheDev merged commit ccc6ca9 into RykoTheDev:main Sep 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants