feat(harmonyos): tell the caller when an open re-activates an already-foreground app
Summary
Reopening an app that already holds the foreground ran the launch dispatch with no visible effect and no output, so a caller could only guess that --relaunch restarts. HarmonyOS now reads the foreground bundle before the dispatch on plain opens only: --relaunch, --clear-app-state, --activity, and URL/deep-link opens skip the read, since each stops or replaces the running app. The outcome carries alreadyForeground and the daemon appends the warning App was already foreground; open re-activated it without restarting. Use --relaunch to restart. A failed probe, or one naming another app, claims nothing.
Before / after
open com.example.app with that app already foreground (HarmonyOS):
base 357e0d4a7: {"ok":true,"data":{"session":"harmony","appBundleId":"com.example.app"}}
head: {"ok":true,"data":{..., "warnings":["App was already foreground; open re-activated it without restarting. Use --relaunch to restart."]}}
Validation
Live at 1720afe4b on the physical unit (华为畅享 90 Plus; captured at the pre-rebase tree 575227b0b), per the review protocol: (1) second open on a foreground target warns and the ability pid is unchanged (40798 → 40798) — no restart; (2) another app foreground, no warning; (3) --activity open, no warning and no probe; (4) --relaunch restarts for real (40752 → 40798) with no probe; (5) alternating latency blocks show no probe cost (plain 0.46–0.65s vs relaunch 0.56–0.57s). Detail in the evidence comment. Unit tests: contracts probe, app-state parse, daemon warning; tsc -b clean; after the rebase contracts 804, daemon session-lifecycle 242, harmonyos 135 tests pass.
🤖 Generated with Claude Code