Skip to content

fix(v3): start default signal handler during App.Run - #6098

Merged
leaanthony merged 3 commits into
masterfrom
fix/6096-signal-handler
Sep 13, 2026
Merged

leaanthony merged 3 commits into
masterfrom
fix/6096-signal-handler

Conversation

@leaanthony

@leaanthony leaanthony commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Description

SIGINT and SIGTERM previously terminated v3 desktop apps without calling App.Quit(), so service shutdown and other cleanup hooks were skipped. Move signal-handler setup from New() to Run(), after successful startup, and start the handler there. DisableDefaultSignalHandler remains respected, and both iOS and Android use no-op setup managed by their platform lifecycle.

Adds subprocess regression tests for SIGINT and SIGTERM with the handler enabled and disabled. The tests verify dispatch to App.Quit() and normal OS termination when disabled.

Fixes #6096.

Validation

  • go test ./pkg/application ./internal/signal -count=1: passed on macOS arm64.
  • Signal regression tests fail with the Start() call removed and pass with it restored.
  • go test -race ./pkg/application -run '^TestDefaultSignalHandler' -count=1: passed.
  • Focused server-mode signal and server lifecycle tests: passed.
  • Real macOS app: both SIGINT and SIGTERM invoke ServiceShutdown and PostShutdown and exit successfully; disabling the handler preserves OS signal termination.
  • Platform-selection regression tests cover Darwin, Linux, Windows, iOS, and Android, with and without the server tag. The Android cases fail when its exclusion is removed.
  • GOOS=android GOARCH=arm64 CGO_ENABLED=0 go build ./pkg/application: passed.
  • git diff --check: passed. CodeRabbit reviewed all three changed files with zero findings.

The full server-mode application suite fails TestSystemModes and TestIsPlatform, which assume desktop mode; both failures reproduce on the unchanged base. Windows and Linux runtime behavior was not exercised locally.

Summary by CodeRabbit

  • Bug Fixes

    • Improved application shutdown handling so interrupt and termination signals are processed correctly after startup.
    • Ensured enabled signal handlers trigger a graceful application quit, while disabled handlers retain standard operating-system behavior.
    • Improved signal-handling behavior across desktop, iOS, and Android platforms.
  • Tests

    • Added coverage for desktop interrupt and termination scenarios.
    • Added verification for platform-specific signal-handler selection.

Copilot AI lite review requested due to automatic review settings September 9, 2026 21:34
@github-actions github-actions Bot added Bug Something isn't working v3 labels Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d4485962-d5bb-49fa-9dff-cdbc079379e2

📥 Commits

Reviewing files that changed from the base of the PR and between 599bb6e and fe69f29.

📒 Files selected for processing (1)
  • v3/pkg/application/application.go

Walkthrough

The application now starts the default desktop signal handler from Run after startup. Build-variant tests verify platform selection. Integration tests verify SIGINT and SIGTERM behavior when handling is enabled or disabled.

Changes

Signal handling lifecycle

Layer / File(s) Summary
Run-time signal handler startup
v3/pkg/application/application.go, v3/pkg/application/signal_handler_desktop.go, v3/pkg/application/signal_handler_android.go
Signal handler setup moved from application construction to Run. Desktop setup starts the handler. Android uses a matching no-op method, and desktop builds exclude Android.
Signal handling integration and build tests
v3/pkg/application/signal_handler_desktop_test.go, v3/pkg/application/signal_handler_test.go
Subprocess tests verify App.Quit for enabled handling and normal OS termination when handling is disabled. Build-context tests verify desktop, iOS, and Android file selection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant SignalHandler
  participant OS
  App->>App: Run completes startup
  App->>SignalHandler: setupSignalHandler(options)
  App->>SignalHandler: Start()
  OS->>SignalHandler: SIGINT or SIGTERM
  SignalHandler->>App: Quit()
Loading

Suggested reviewers: taliesin-ai

Merge Risk: ⚪ Minimal · up to 599bb

Default desktop SIGINT and SIGTERM handling now routes through application shutdown after startup, while disabled handling and mobile platform behavior remain preserved. The covered behavior is ready to merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the fix, motivation, issue number, tests, and known validation limits. However, it omits the required Type of change section, Test Configuration with wails doctor output or en… Add the Type of change selection, provide the Test Configuration section with wails doctor output or a detailed environment description, and complete each applicable checklist item.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #6096. The default signal handler starts during App.Run, respects DisableDefaultSignalHandler, routes SIGINT and SIGTERM through App.Quit when enabled, preserves OS terminati…
Out of Scope Changes check ✅ Passed The implementation changes and regression tests are directly related to signal-handler startup, platform build selection, and the shutdown behavior required by issue #6096. No unrelated code changes a…
Title check ✅ Passed The title clearly and concisely describes the primary change: starting the default signal handler during App.Run.
Full details: Description check

Explanation

The description explains the fix, motivation, issue number, tests, and known validation limits. However, it omits the required Type of change section, Test Configuration with wails doctor output or environment details, and the checklist responses.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/6096-signal-handler

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The desktop signal handler now starts on Android as well due to build constraints, which is likely unintended and should be guarded or split by platform.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes v3 apps bypassing App.Quit() on SIGINT/SIGTERM by starting the default signal handler during App.Run() (after successful startup), and adds regression tests that validate both enabled and disabled behavior.

Changes:

  • Move default signal-handler setup from New() to Run() after startup completes.
  • Start the default signal handler (SignalHandler.Start()) when it is configured.
  • Add subprocess-based regression tests for SIGINT/SIGTERM (handler enabled vs disabled).
File summaries
File Description
v3/pkg/application/application.go Moves signal-handler setup to App.Run() after successful startup.
v3/pkg/application/signal_handler_desktop.go Starts the default signal handler when it is created.
v3/pkg/application/signal_handler_desktop_test.go Adds subprocess regression tests for SIGINT/SIGTERM behavior with the handler enabled/disabled.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3] Default signal handler is constructed but never started — SIGINT/SIGTERM bypass App.Quit and all shutdown hooks

3 participants