Skip to content

Fix "Stop Gateway" button not killing gateway process, and misleading storage warning icon#104

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-stop-gateway-button-issue
Draft

Fix "Stop Gateway" button not killing gateway process, and misleading storage warning icon#104
Copilot wants to merge 3 commits intomainfrom
copilot/fix-stop-gateway-button-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

Two bugs: (1) the "Stop Gateway" button left the openclaw/node.js daemon running after clicking it, requiring openclaw gateway stop from the terminal to actually stop it; (2) the Settings screen showed an amber warning on the Storage tile regardless of grant state, making the safe (not-granted) state visually indistinguishable from the risky (granted) state.

Stop Gateway — SIGKILL bypasses proot's child cleanup

stopGateway() was calling destroyForcibly() (SIGKILL) directly on the proot process. SIGKILL skips proot's --kill-on-exit exit handler, so child processes (node.js / openclaw daemon) survive proot's death.

Fix: Send SIGTERM first via proc.destroy(), wait up to 3 s for a clean exit, then fall back to ProcessHandle.descendants().forEach { destroyForcibly() } + destroyForcibly() on the proot handle itself. Also interrupt gatewayThread immediately so any in-flight auto-restart sleep wakes up and respects stopping=true.

// Before
gatewayProcess?.let {
    it.destroyForcibly()   // SIGKILL — proot exit handler never runs
    gatewayProcess = null
}

// After (runs in named daemon thread "gateway-stop")
proc.destroy()             // SIGTERM — proot --kill-on-exit kills children
if (!proc.waitFor(3, TimeUnit.SECONDS)) {
    proc.toHandle().descendants().forEach { it.destroyForcibly() }
    proc.destroyForcibly()
}

Settings storage tile — warning shown for safe (not-granted) state

Both granted and not-granted storage states displayed an amber warning icon. Not granting storage is the recommended state (per README); the icon should be green, mirroring the Battery Optimization tile's convention.

  • Not granted: Icons.warning (amber) → Icons.check_circle (green); subtitle updated to "Not granted (recommended) — tap to grant only if needed"
  • Granted: amber warning unchanged — this state is still flagged as potentially risky

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
- GatewayService.stopGateway(): switch from SIGKILL (destroyForcibly) to
  SIGTERM (destroy) + 3 s grace period so proot's --kill-on-exit handler can
  kill its child processes (node.js / openclaw daemon) before proot exits.
  Fall back to ProcessHandle.descendants() + destroyForcibly if proot does
  not exit in time. Also interrupt gatewayThread so auto-restart sleep wakes
  immediately when stopping. Adds descriptive thread name 'gateway-stop'.
- SettingsScreen: Storage tile not-granted state now shows green check icon
  (safe/recommended) instead of amber warning. Updated subtitle to clarify
  that not granting storage is the recommended state.

Agent-Logs-Url: https://github.com/mithun50/openclaw-termux/sessions/9c54b2bb-d170-497f-b4d9-f83b108580bb

Co-authored-by: mithun50 <99024517+mithun50@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 'Stop Gateway' button not functioning correctly Fix "Stop Gateway" button not killing gateway process, and misleading storage warning icon Apr 2, 2026
Copilot AI requested a review from mithun50 April 2, 2026 06:53
@mithun50
Copy link
Copy Markdown
Owner

mithun50 commented Apr 2, 2026

@copilot is it ready

Copy link
Copy Markdown
Author

Copilot AI commented Apr 2, 2026

@copilot is it ready

Yes, the PR is ready. Two fixes are included in commit b54f398:

1. "Stop Gateway" button — Previously destroyForcibly() (SIGKILL) was sent directly to proot, bypassing its --kill-on-exit handler that kills child processes. The fix sends SIGTERM first (giving proot 3 s to clean up node.js/openclaw), then falls back to killing the full process tree if needed.

2. Settings — Storage icon — The amber warning was shown for both granted and not-granted states. Since not granting storage is the safe/recommended state, it now shows a green check (matching Battery Optimization), while the granted state keeps the amber warning. The subtitle also now clearly says "Not granted (recommended)".

The screenshot in the issue shows the granted state correctly — amber warning is expected when storage access has been granted.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Build Failed

The build failed for commit e2329d3.

View build logs

@mithun50
Copy link
Copy Markdown
Owner

mithun50 commented Apr 2, 2026

@copilot workflow failed investigate it

…e with JVM target 1.8

Agent-Logs-Url: https://github.com/mithun50/openclaw-termux/sessions/3756d90a-f158-4349-b3e6-d5f489dc81e4

Co-authored-by: mithun50 <99024517+mithun50@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Apr 2, 2026

@copilot workflow failed investigate it

Found and fixed the build failure in commit bd4ef7d.

Root cause: The project targets JVM 1.8 (jvmTarget = JavaVersion.VERSION_1_8 in build.gradle), but my code used Process.toHandle() which is a Java 9+ API. This caused the Kotlin compiler to fail with Unresolved reference: toHandle.

Fix: Removed the ProcessHandle.descendants() tree-kill block. The stop sequence is still correct — SIGTERM is sent first (giving proot 3 s to run its --kill-on-exit handler and kill child processes), then falls back to destroyForcibly() (SIGKILL) on proot itself if it doesn't exit in time.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Build Successful

Version: v1.8.6

Download APKs

Architecture Download
arm64-v8a (recommended) OpenClaw-v1.8.6-arm64-v8a.apk
armeabi-v7a (32-bit) OpenClaw-v1.8.6-armeabi-v7a.apk
x86_64 (emulator) OpenClaw-v1.8.6-x86_64.apk
Universal (all ABIs) OpenClaw-v1.8.6-universal.apk
App Bundle (Play Store) OpenClaw-v1.8.6.aab

Download from Actions Artifacts


Built from 1100063 by GitHub Actions

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.

"Stop Gateway" button issue

2 participants