Repository navigation
feat(harmonyos): tell the caller when an open re-activates an already-foreground app - #4860
Conversation
|
Thanks for the PR. At a6f3e19 the change is not ready: it has no live HarmonyOS evidence, and the new message is wrong on one reachable route. CI is green, and the earlier Body rules failure graded the PR body, not code; the rerun after the body edit passes. HarmonyOS has no CI device, so green CI says nothing about the changed device path. No conflicts. Before merge, the live run below and the two fixes are needed. The change is device-facing: it adds an The foreground read happens before the open options are applied (application-lifecycle-interaction.ts:328). With The warning says "dispatch skipped" (session-open-execution.ts:180). The dispatch is not skipped: Not blocking, take or leave: Could the read live inside the HarmonyOS owner instead? Not verified here: the passthrough premise and the real |
|
Both required fixes are in at 0f36cec:
Live run status: the protocol you specified is staged, but the HarmonyOS unit is currently claimed live by an unrelated workspace's session ( On the ownership question: agreed the live run decides it. If the second dispatch is a no-op, folding the read into |
6b6bfa0 to
454be7c
Compare
|
The Coverage failure here is inherited from main: main HEAD |
|
Thanks for the follow-up. The earlier fixes at 454be7c look right: plain opens only probe now, and clear-app-state and --activity opens skip the probe. The required live run on a HarmonyOS device is still missing. Required live evidence is still missing for the probe in https://github.com/callstack/agent-device/blob/454be7ce2/packages/platform-harmonyos/src/app-state.ts#L38. The change adds an Would it be simpler to keep Not blocking, take or leave: the PR body still names a6f3e19, quotes the old "App already foreground; dispatch skipped." warning, and does not mention the clear-app-state and --activity exclusion, so please update it to the 454be7c wording when the live evidence is posted. Only the Coverage job fails, on run 44929373306. Main at 4075dd1, the merge-base, fails the same job and step, and #4915 (open) documents that main's Coverage has been red because website/docs/docs/commands.md is stale. This PR touches no command help, registry or commands.md, so the failure looks unrelated. Not verified here: a second failure hidden behind the shared one, and the tests were not run locally. Before merge, the live HarmonyOS run at 454be7c must be posted and main's Coverage must go green after #4915. |
454be7c to
575227b
Compare
|
The five live runs are in, on the physical unit (华为畅享 90 Plus, (1) Target already foreground — second (2) Another app foreground — no warning. After (3) (4) (5) Latency, alternating blocks (plain open = probe, relaunch = no probe), same bundle and device:
The probe's marginal cost is invisible against open variance (a standalone On the ownership question: the run answers it — the second The Body rules gate reads the refreshed body (454be7c wording, the exclusion, this head). |
|
Thanks for the quick follow-up. The earlier findings from #4860 (comment) are now fixed at 575227b, and the live results you posted in comment 7074486267 cover the main routes. All 16 checks pass at 575227b, and the earlier Coverage failure from main is gone after the rebase onto d6767e0. There are no conflicts. Not verified here: the live HarmonyOS results, since no device or hdc was available for a re-run; the |
|
Head 575227b now conflicts with main. Please rebase onto current main and push; the open evidence request from the earlier review (#4860 (comment)) still applies to the rebased head. |
…-foreground app A second `open` of an app that already holds the foreground ran its launch dispatch with no visible effect and no output line, so the caller could only guess that `--relaunch` was the restart path. HarmonyOS now reads which bundle holds the foreground before the dispatch, and the open outcome carries that fact; `completeOpenCommand` adds the warning line to the open result beside its other notes. The open keeps its idempotent semantics: the dispatch still runs, and a probe that fails or names another app claims nothing. The read is advisory at the shared direct lifecycle: an owner that does not wire it (Linux, web, Vega) answers exactly as before. Co-Authored-By: Claude Code <noreply@anthropic.com>
…e app A --clear-app-state or --activity open stops or replaces the running app, so the pre-dispatch foreground read has no same-app fact to compare and claimed a re-activation the open itself was about to end. The warning also said "dispatch skipped" when aa start still ran; it now says what happened and names --relaunch. Co-Authored-By: Claude Code <noreply@anthropic.com>
The previous full-suite coverage run raced a parallel PR's run and died mid-suite with no assertion failure; the affected suites pass locally. Co-Authored-By: Claude Code <noreply@anthropic.com>
575227b to
1720afe
Compare
|
Rebased onto upstream main |
|
Thanks for the rebase. The conflict from the earlier review is fixed at 1720afe, and the code now looks good to merge. The pre-dispatch probe and the post-open foreground poll from #4293 compose correctly: Not verified here: live HarmonyOS behavior at this head, because no device or hdc was available. The earlier live results were captured at 575227b, and the patch is unchanged apart from context and the One question, which is optional: the probe uses a fixed 15s hdc timeout that is not clamped to the request deadline, unlike the #4293 poll. Should it share that clamp, so a hung |
|
Yes — it should share the clamp: a hung The probe is part of this PR's diff, so I'll send the clamp as a tiny follow-up the moment this merges (default), unless you'd rather see it pushed onto this branch — that would restart the review clock on an otherwise-ready PR, so I won't do that unilaterally. |
Three take-or-leave items from the callstack#5055 review. The open lifecycle binds readForegroundBundle as DirectApplicationLifecycleParams' own shape, so the contract owns the type. The remaining-read-budget clamp arithmetic (Math.min against a read's default, floored at 0, spent deadline answers 0) moves to one helper beside hdc.ts that both the open-time probe and the post-open poll budget call. The probe's doc comment now says the clamp bounds the read, not the dispatch it precedes. Follow-up to the optional question the callstack#4860 review left open. Co-Authored-By: Claude Code <noreply@anthropic.com>
…uest deadline (#5055) * fix(harmonyos): clamp the open foreground probe's hdc read to the request deadline The pre-dispatch already-foreground probe ran one `aa dump -l` read on a fixed 15s timeout, so a hung read could hold the dispatch past a request deadline the post-open foreground poll (#4293) would have respected. The probe now receives the request's deadline beside the signal, clamps its read to the remaining budget (Math.min against the 15s default), skips the device entirely when a spent deadline leaves no room for one read, and still claims nothing when the deadline or a cancel cuts the read — the advisory outcome machinery is unchanged and no reason set grows. Follow-up to the optional question the #4860 review left open. * test: retrigger the android emulator smoke lane (no code change) * docs(evidence): record the JDY-AL50 live runs for the open probe deadline clamp Scenario a: the already-foreground open answers with the alreadyForeground warning at 0.7 s with no added probe latency. Scenario b: an hdc wrapper that sleeps on the probe read cannot hold the dispatch past the admitted request budget — the probe read dies at its 15 s clamp, the poll read at its 5 s budget, and the open returns with the advisory unreadable warning and no alreadyForeground claim. The 2-3 s remaining-deadline variant is not expressible on the shipped CLI (open's result budget is a fixed 60 s floor and the pre-probe route spends at most ~10 s), so the clamp below 15 s stays pinned by the unit suite; the live run is the wiring half of that proof. Refs #5055 * docs(evidence): run the 2-3s deadline replay variant live on the JDY-AL50 * docs(evidence): format the part-b replay JSON artifacts * refactor(harmonyos): take the review polish on the open probe clamp Three take-or-leave items from the #5055 review. The open lifecycle binds readForegroundBundle as DirectApplicationLifecycleParams' own shape, so the contract owns the type. The remaining-read-budget clamp arithmetic (Math.min against a read's default, floored at 0, spent deadline answers 0) moves to one helper beside hdc.ts that both the open-time probe and the post-open poll budget call. The probe's doc comment now says the clamp bounds the read, not the dispatch it precedes. Follow-up to the optional question the #4860 review left open. Co-Authored-By: Claude Code <noreply@anthropic.com> * docs(evidence): re-run the deadline replay leg at the polish head 9e23b8a Same replay route on the JDY-AL50 at the review-polish code SHA, screen PIN-locked: the probe's aa dump -l read lived 2.23s under a 3s replay deadline (cut at +3.29s, not 25s wrapper, not 15s default), the aa start dispatch followed without waiting on the hung read, and the request settled daemon_request_timeout with no alreadyForeground claim. Names the observed hdc resolution mechanism: the daemon prefers its toolchain roots over PATH, so the wrapper rides HDC_SDK_PATH. Co-Authored-By: Claude Code <noreply@anthropic.com> * docs(evidence): fix the two review notes on the evidence artifacts Cite the evidence commits that exist in this PR's history instead of the unreferenced 66e129b, and scrub the local absolute paths from the committed replay JSON artifacts (repo-relative script paths, placeholder state dir). Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: strzhao <strzhao@users.noreply.github.com> Co-authored-by: Claude Code <noreply@anthropic.com>
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
--relaunchrestarts. 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 carriesalreadyForegroundand the daemon appends the warningApp 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.appwith that app already foreground (HarmonyOS):Validation
Live at 1720afe on the physical unit (华为畅享 90 Plus; captured at the pre-rebase tree 575227b), 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)--activityopen, no warning and no probe; (4)--relaunchrestarts 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 -bclean; after the rebase contracts 804, daemon session-lifecycle 242, harmonyos 135 tests pass.🤖 Generated with Claude Code